// JavaScript Document

function doSearch() {
	if (document.forms['searchform'].search.value != "") { 
		document.searchform.submit();
	}
}

function doSubscribe() {
	var allValid = 0;
	if (document.forms['subscribe'].subscribe_email.value != "") {
		if (!checkEMail(document.forms['subscribe'].subscribe_email.value)) {
			alert('E-Mail: Please enter valid email address');
			document.forms['subscribe'].subscribe_email.focus();
			allValid = 0;
		} else {
			allValid = 1;
			if (document.forms['subscribe'].subscribe_name1.value == "") {
//				alert('Last Name: Please enter Last Name');
				document.forms['subscribe'].subscribe_name1.focus();
				allValid = 0;
			} else {
				allValid = 1;
			}
		}
	} else {
//			alert('E-Mail: Please enter email address');
			document.forms['subscribe'].subscribe_email.focus();
			allValid = 0;
	}
	if (allValid) {
		document.subscribe.submit();
	}
}

function doSearchRun() {
	document.searchform.submit();
}

function checkNumber(text) {
	var checkOK = "0123456789-+ ";
	var checkStr = text;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	return allValid;
}

function checkEMail(text) { 
	txt=text;
	if (txt == "") { return(false) } 
	if (txt.indexOf(".") == -1) { return(false) } 
	dog = txt.indexOf("@"); 
	if (dog == -1) { return(false) } 
	if ((dog < 1) || (dog > txt.length - 5)) { return(false) } 
	if ((txt.charAt(dog - 1) == '.') || (txt.charAt(dog + 1) == '.')) { return(false) } 
	return(true);
} 

// Menu
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
function doPreloadImage() { 
//	MM_preloadImages('imdesign/menu/menu01b.jpg','imdesign/menu/menu02b.jpg','imdesign/menu/menu03b.jpg','imdesign/menu/menu04b.jpg','imdesign/menu/menu05b.jpg','imdesign/menu/menu06b.jpg');
//	MM_preloadImages('imdesign/menu/menu01c.jpg','imdesign/menu/menu02c.jpg','imdesign/menu/menu03c.jpg','imdesign/menu/menu04c.jpg','imdesign/menu/menu05c.jpg','imdesign/menu/menu06c.jpg');
}
// end Menu

// Cookie
function setCookie(name, value) {
        document.cookie = name + "=" + escape(value)+"; path=/; expires=Thursday, 31-Dec-2020 23:59:59 GMT;";
}

function setCookieNow(name, value) {
        document.cookie = name + "=" + escape(value)+"; path=/; expires=Thursday, 31-Dec-2020 23:59:59 GMT;";
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return ''
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
// end Cookie

function newopen(filename, imgtext) {
	var width = screen.availWidth-30;
	var height = screen.availHeight-40;
	var left = (screen.width/2) - (width/2)-5;
	var top = (screen.height/2) - (height/2)-30;

	new_window=window.open("about:blank","_blank","width="+width+", height="+height+", scrollbars=no, resizable=no, left="+left+", top="+top);
	new_window.document.open("text/html");
	new_window.document.writeln("<HTML><HEAD><META http-equiv=Content-Type content=text/html; charset=windows-1251>");
	new_window.document.write("<TITLE>");
	new_window.document.write(imgtext);
	new_window.document.writeln("</TITLE>");
	new_window.document.writeln("</HEAD>");
	new_window.document.writeln("<BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>");
	new_window.document.writeln("<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center bgcolor=#CCCCCC>");
	new_window.document.writeln("<img src="+filename+" onClick=\"window.close();\"");
	new_window.document.writeln("</td></tr></table>");
	new_window.document.write("</BODY></HTML>");
	new_window.document.close();
}

