var count=0;//做计数器
var limit=new Array();//用于记录当前显示的哪几个菜单
var countlimit=1;//同时打开菜单数目，可自定义
function expandIt(el) {
obj = eval("sub" + el);
	if (obj.style.display == "none") {
		obj.style.display = "block";//显示子菜单
		if (count<countlimit) {//限制2个
		limit[count]=el;//录入数组
		count++;
		}
		else {
		eval("sub" + limit[0]).style.display = "none";
		for (i=0;i<limit.length-1;i++) {limit[i]=limit[i+1];}//数组去掉头一位，后面的往前挪一位
		limit[limit.length-1]=el;
		}
	}
	else {
	obj.style.display = "none";
	var j;
	for (i=0;i<limit.length;i++) {if (limit[i]==el) j=i;}//获取当前点击的菜单在limit数组中的位置
	for (i=j;i<limit.length-1;i++) {limit[i]=limit[i+1];}//j以后的数组全部往前挪一位
	limit[limit.length-1]=null;//删除数组最后一位
	count--;
	}
}














var max_menu=1000;

var menu_array=new Array();
for (i=0; i<=max_menu; i++){
        menu_array[i]=0;
}

var select_method; //DOM type
var nn=false;
var domb=false;
var msie=false;

function set_browser(){
        if (document.getElementById){
                select_method="getElementById";
                domb=!domb;

        }
        else if (document.all){
                select_method="all";
                msie=!msie

        }
        else if (document.layers){
                nn=!nn;
        }
        else {
                alert("Browser is not defined!");
        }
}

set_browser();

function set_visible_ie(div_id){
        eval("document."+select_method+"('id"+div_id+"').style.visibility='visible'");
        eval("document."+select_method+"('id"+div_id+"').style.position='relative'");
        eval("document."+select_method+"('id"+div_id+"').style.top='0px'");
        eval("document.arrow_"+div_id+".src='imgs/menu-arrow-down.gif'");
}

function set_hide_ie(div_id){
        eval("document."+select_method+"('id"+div_id+"').style.visibility='hidden'");
        eval("document."+select_method+"('id"+div_id+"').style.position='absolute'");
        eval("document."+select_method+"('id"+div_id+"').style.top='-2000px'");
        eval("document.arrow_"+div_id+".src='imgs/menu-arrow-left.gif'");
}

function set_change(div_id){
        if ((domb)||(msie)){
                if (menu_array[div_id]==0){
                        set_visible_ie(div_id);
                        menu_array[div_id]=1;
                }
                else {
                        set_hide_ie(div_id);
                        menu_array[div_id]=0;
                }
        }
}

function onChange(i){
childSort=document.all("child" + i);
//theTd=document.all("td" + i);
	if(childSort.style.display=="none"){
//		theTd.bgcolor="#ffffff";
		childSort.style.display="";}
	else{
//		theTd.bgcolor="#000000";
		childSort.style.display="none";}
}

function show_block(div_id){
        if (!nn){
                eval("document."+select_method+"('"+div_id+"').style.visibility='visible'");
                eval("document."+select_method+"('"+div_id+"').style.position='relative'");
                eval("document."+select_method+"('"+div_id+"').style.top='0px'");
                }
        }

// POPUP FUNCTIONS

var scr_height=800;
var scr_width=600;
var win_height;
var win_width;

if (screen.availHeight){
var scr_height=screen.availHeight;
var scr_width=screen.availWidth;
}

// PARAMS FOR POPUP

        win_height=560;
        win_width=620;
        win_top=scr_height/2-win_height/2;
        win_left=scr_width/2-win_width/2;
        win_dimensions="height="+win_height+",width="+win_width+", top="+win_top+", left="+win_left+", status, scrollbars, resizable";
        win_dimensions2="status, scrollbars, resizable";
        win_tshirt="width=689,height=560,scrollbars=yes,resizable=no";

function show_basket()
{
        basketball = window.open("http://www.artmam.com/payment/basket/basket.php","basketball",win_dimensions);
        if (basketball){basketball.focus();}
}


function return_to_basket()
{
        basketball = window.open("http://www.artmam.com/payment/basket/basket.php","basketball",win_dimensions);
        if (basketball){basketball.focus();}
}

function show_service(s,name,p1,p2,p3,p4)
{
    if (s=="offer_price"){
                offer = window.open("http://artmam.com/addon/offer_price.php","offer",win_dimensions);
                if (offer){offer.focus();}
        }
        if (s=="ask_about"){
            params = "?good_url=http://"+name+"&dom="+p1;
                about = window.open("http://artmam.com/addon/ask_about.php"+params,"about",win_dimensions);
                if (about){about.focus();}
        }
        if (s=="send_to_friend"){
            params = "?server=http://"+name+"/&good_id="+p1+"&good_title="+p2+"&good_img="+p3+"&dom="+p4;
                friend = window.open("http://artmam.com/addon/send_to_friend.php"+params,"friend",win_dimensions);
                if (friend){friend.focus();}
        }
        if (s=="buy_original" || s=="buy"){
                basketball = window.open("","basketball",win_dimensions);
                document.basform.submit();
                if (basketball){basketball.focus();}
        }
        if (s=="buy_poster"){
            params = "?dom="+name+"&image="+p1;
                posters = window.open("http://artmam.com/addon/posters.php"+params,"posters",win_dimensions2);
                if (posters){posters.focus();}
        }
        if (s=="buy_print"){
            params = "?dom="+name+"&image="+p1+"&pid="+p2+"&good_id="+p3;
                prints = window.open("http://artmam.com/addon/print.php"+params,"prints",win_dimensions2);
                if (prints){prints.focus();}
        }
        if (s=="t_shirt"){
            params = "?dom="+name+"&image="+p1;
                tshirt = window.open("http://t-shirt.artmam.com/"+params,"tshirt",win_tshirt);
                if (tshirt){tshirt.focus();}
        }
        if (s=="mobile"){
                Photoperso = window.open("http://www.sonnerie.net/photoperso/index02.php?la=EN&a=napoleon&url=http://artmam.com/all/shop/Good/"+name,"Photoperso",'width=640 height=600 scrollbar=no toolbar=no');
                if (Photoperso){Photoperso.focus();}
        }
        if (s=="posters"){
                buy_posters = window.open("http://artmam.com/posters/index.php","buy_posters","height=749,width=590,scrollbars=yes");
                if (buy_posters){buy_posters.focus();}
        }
        if (s=="policy"){
                 policy = window.open("http://artmam.com/payment/basket/other/policy.html","policy","height=330,width=610,scrollbars=yes");
                if (policy){policy.focus();}
        }
}

// CHECK FUNCTIONS

function test_field()
{
        if (document.op_form.email.value=="") {alert ("Enter your e-mail so that we may contact you.")}
        else { document.op_form.submit(); }
}

function test_feedback()
{
        if ((document.fb_form.name.value=="") || (document.fb_form.mess.value=="")) {alert ("Enter your name and message, please.")}
        else { document.fb_form.submit(); }
}

//Old functions. created by Vova. added by Kull

var i=11;
var flag=true;
var flag2=true;
function set_bg(c){
    switch(c){
      case 10:
        c="a"
        break
      case 11:
        c="b"
        break
      case 12:
        c="c"
        break
      case 13:
        c="d"
        break
      case 14:
        c="e"
        break
      case 15:
        c="f"
        break
    }

  if (document.getElementById){
    document.getElementById("email").style.backgroundColor="#"+c+"c"+c;
  }
}
function bg_anim(){
  if (flag){
    i++;
    if (i==14) flag=!flag;
  }
  if (!flag){
    i--;
    if (i==11) flag=!flag;
  }
  set_bg(i);
  if (flag2){
    var timeout_id=setTimeout("bg_anim()",300);
  }
  else {
    if (document.getElementById){
      document.getElementById("email").style.backgroundColor="#fff";
      if (document.getElementById("email").value=="Your e-mail"){
        document.getElementById("email").value="";
      }
    }
  }
}

function stop_splash(){
  flag2=!flag2;
}

function start_splash(){
  flag2=!flag2;
  bg_anim();

}

function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}


function check0()
{ 
	if(checkspace(document.ckxp0.username.value)) {
		document.ckxp0.username.focus();
		alert("User name can not be empty, please re-enter!");
		return false;
  }
  }

function checkuserinfo()
{ 

      if(checkspace(document.userinfo.username.value)) {
	document.userinfo.username.focus();
    alert("User name can not be empty, please re-enter!");
	return false;
  }

   if(checkspace(document.userinfo.userpassword.value) || document.userinfo.userpassword.value.length < 6) {
	document.userinfo.userpassword.focus();
    alert("Password length is not less than 6, please re-enter!");
		return false;
	  }
  
    if(document.userinfo.userpassword.value != document.userinfo.userpassword1.value) {
	document.userinfo.userpassword.focus();
	document.userinfo.userpassword.value = '';
	document.userinfo.userpassword1.value = '';
    alert("Two different password, please re-enter!");
	return false;
	  }

if(document.userinfo.useremail.value.length!=0)
	  {
		if (document.userinfo.useremail.value.charAt(0)=="." ||        
			 document.userinfo.useremail.value.charAt(0)=="@"||       
			 document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
			 document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
			 document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
			 document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
			 {
			  alert("Email address format is not correct!");
			  document.userinfo.useremail.focus();
			  return false;
			  }
	   }
	 else
	  {
	   alert("Email can not be empty!");
	   document.userinfo.useremail.focus();
	   return false;
	   }
   
   
/*   if(checkspace(document.userinfo.userzhenshiname.value)) {
	//document.userinfo.userzhenshiname.focus();
 //   alert("真实姓名不能为空，请重新输入！");
//	return false;
 // }
 //  if(document.userinfo.quesion.value.length<8) {
///	document.userinfo.quesion.focus();
    alert("密码提示问题不能为空！");
	return false;
  }
   if(document.userinfo.answer.value.length<8) {
	document.userinfo.answer.focus();
    alert("密码提示问题答案不能为空！");
	return false;
  }*/
}







function checkshouhuoxx()
{
  if(checkspace(document.shouhuoxx.shouhuodizhi.value)) {
	document.shouhuoxx.shouhuodizhi.focus();
    alert("Excuse me, please fill out the address of the consignee detailed receipt!");
	return false;
  }
  if(checkspace(document.shouhuoxx.youbian.value)) {
	document.shouhuoxx.youbian.focus();
    alert("Excuse me, please fill out the Zip!");
	return false;
  }
  if(document.shouhuoxx.youbian.value.length!=6) {
	document.shouhuoxx.youbian.focus();
    alert("Excuse me, please fill out the correct ZIP!");
	return false;
  }



  if(checkspace(document.shouhuoxx.songhuofangshi.value)) {
	document.shouhuoxx.songhuofangshi.focus();
    alert("Sorry, you do not select shipping method!");
	return false;
  }
  if(checkspace(document.shouhuoxx.zhifufangshi.value)) {
	document.shouhuoxx.zhifufangshi.focus();
    alert("Sorry, you do not have to choose methods of payment!");
	return false;
  }
}


function checkspace(checkstr) {
   var str = '';
   for(i = 0; i < checkstr.length; i++) {
     str = str + ' ';
   }
   return (str == checkstr);
}


function check_loginfo()
{
  if(checkspace(document.loginfo.username.value)) {
	document.loginfo.username.focus();
    alert("Sorry，username is necessary！");
	return false;
  }
  if(checkspace(document.loginfo.userpassword.value)) {
	document.loginfo.userpassword.focus();
    alert("Sorry，user password is necessary！");
	return false;
  }
}