function confirm_delete()
{
	var val;
	val = confirm("Do you want to delete?");
	return val;
}


function confirm_deny()
{
	var val;
	val = confirm("Do you want to deny request?");
	return val;
}


function change_color(tr)
{
	
  if(document)
  {
     document.getElementById(tr).style.backgroundColor = '#d5e5de';  
  }
}

function change_color1(tr)
{
  var no ;
  no = tr.substr(2,tr.length);
   if(document)
  {
    if( no%2 == 0)
	 document.getElementById(tr).style.backgroundColor = '#ffffff';  
    else
	document.getElementById(tr).style.backgroundColor = '#f5f7f9';  
  }
}



function admin_set_focus_login()
{
document.getElementById("login").focus();
}


function show_popup(str)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=400,height=300,top=20,left=100';
  window.open(str, "_blank", arg);
}



function chcek_numeric(e)
{
	
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 47 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 47 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}


function chcek_float(e)
{
		
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 46 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 46 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}




function check_date(fld) {
	
  
    var mo, day, yr;
    var entry = fld.value;
    var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
    var valid = (reLong.test(entry)) || (reShort.test(entry));
    if (valid) {
        var delimChar = (entry.indexOf("/") != -1) ? "/" : "-";
        var delim1 = entry.indexOf(delimChar);
        var delim2 = entry.lastIndexOf(delimChar);
        mo = parseInt(entry.substring(0, delim1), 10);
        day = parseInt(entry.substring(delim1+1, delim2), 10);
        yr = parseInt(entry.substring(delim2+1), 10);
        // handle two-digit year
        if (yr < 100) {
            var today = new Date( );
			// get current century floor (e.g., 2000)
            var currCent = parseInt(today.getFullYear( ) / 100) * 100;
			// two digits up to this year + 15 expands to current century
            var threshold = (today.getFullYear( ) + 15) - currCent;
            if (yr > threshold) {
                yr += currCent - 100;
            } else {
                yr += currCent;
            }
        }
        var testDate = new Date(yr, mo-1, day); //alert();
        if (testDate.getDate( ) == day) { 
            if (testDate.getMonth( ) + 1 == mo) {
				var curDate;
                curDate = new Date();
				curDate.setDate(curDate.getDate( ) - 1);
				if(testDate < curDate){
				   alert("You cannot select previous date.");
				   return false;
				}
				if (testDate.getFullYear( ) == yr) {
                    // fill field with database-friendly format
                    fld.value = mo + "/" + day + "/" + yr;
                    return true;
                } else {
                    alert("Invalid year entry.");
                }
            } else {
                alert("Invalid month entry.");
            }
        } else {
            alert("Invalid date entry.");
        }
    } else {
        alert("Incorrect date format. Enter as mm/dd/yyyy.");
    }
    return false;
}







function email_check()
{
	var emailchar = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (emailchar.test(document.getElementById("email").value)){
		return true
	}
	else
	{
		alert("Please, enter a valid email address.");
	}
}

function validaty()
{
	if ( document.getElementById("user_password").value != document.getElementById("re_password").value ) alert("Value of password and retype-password must match!");
}

  //
  // Here nevigation js code are added
  //

  var cookieName = 'navCookie';
  var divNames = new Array("divWelcome","divContent","divSettings","divMember",'divEmail','divOrder','divSize','divFree','divCupon','divShirt','divPage');

  // return object of specified html element 
  function crObj(ob)
  {
	if (document.getElementById(ob)) {
		
		return document.getElementById(ob);
	} else if (document.all) {
	
		return document.all[ob];
	} else {
	
		alert("Javascript Error: Object '" + ob + "' not found!");
	}
  }

  // expand all divs
  function expandAll(ob)
  {
   		for(i = 0; i < divNames.length; i++)
  		{
			document.getElementById(divNames[i]).style.display = 'block';
			document.getElementById('img' + divNames[i].substr(3)).src = './images/minus.gif';
  		}
  }

  // collapse all divs
  function collapseAll(ob)
  {
  		for(i = 0; i < divNames.length; i++)
  		{
			document.getElementById(divNames[i]).style.display = 'none';
			document.getElementById('img' + divNames[i].substr(3)).src = './images/plus.gif';
  		}
  }
  
  // open/close the section div
  function openClose(ob, timg)
  {
	collapseAll(divNames);
	if (ob.style.display != "none") {
	
		ob.style.display= "none";
		timg.src		= "./images/plus.gif";
	} else {
	
		ob.style.display= "block";
		timg.src		= "./images/minus.gif";
	}
  }

  // store the values of section div's display property on cookie
  function setCookie(Cookie, value, expiredays)
  {
  	var ExpireDate = new Date ();
  	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  	document.cookie = Cookie + "=" + escape(value) +
  	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
  }

  // retrieve the values of section div's display property from cookie
  function getCookie(Cookie)
  {
  	if (document.cookie.length > 0)
  	{
  		begin = document.cookie.indexOf(Cookie+"=");
  		if (begin != -1)
  		{
  			begin += Cookie.length+1;
  			end = document.cookie.indexOf(";", begin);
  			if (end == -1) end = document.cookie.length;
  			return unescape(document.cookie.substring(begin, end)); 
  		}
  	}
  	return null;
  }

  // set the section div's display property according to the cookie
  function LoadMenu()
  {
  	cookieMenu = getCookie(cookieName);//alert("--   "+cookieMenu);
  	if(cookieMenu != null)
  	{
  		for(i = 0; i < divNames.length; i++)
  		{
  			if(cookieMenu.indexOf(divNames[i]) != -1)
  			{
  				document.getElementById(divNames[i]).style.display = 'block';
  				document.getElementById('img' + divNames[i].substr(3)).src = './images/minus.gif';
  			}
  			else
  			{
  				document.getElementById(divNames[i]).style.display = 'none';
  				document.getElementById('img' + divNames[i].substr(3)).src = './images/plus.gif';
  			}
  		}
  	}
	else
  	{
  		for(i = 0; i < divNames.length; i++)
  		{
			document.getElementById(divNames[i]).style.display = 'none';
			document.getElementById('img' + divNames[i].substr(3)).src = './images/plus.gif';
  		}
  	}
  }

  // save the values of section div's display property on cookie before unload
  function SaveMenu()
  {
  	var cookiestring = '';

  	for(i = 0; i < divNames.length; i++)
  	{
  		var block = crObj(divNames[i]);

  		if(block.style.display != 'none')
  		{
  			cookiestring += divNames[i] + '|';
  		}
  	}

  	setCookie(cookieName,cookiestring,1);
  }




function set_multiple_domain(str)
{
 var id ;
 status = document.getElementById('domain_no').value;
 str += 'multiple_domain='+status;
 location.href=str;
}

function get_payment_method(str)
{
 var id ;
 id = document.getElementById('payment_method');
 var status;
 status = id.options[id.selectedIndex].value;
 
 if (status != 'E-Check')
 {
    //alert("test");
	if (document.getElementById('credit_card_form')) document.getElementById('credit_card_form').style.visibility = 'visible';
	if (document.getElementById('credit_card_form')) document.getElementById('credit_card_form').style.display = 'block';
	
	
	if (document.getElementById('echeck_form')) document.getElementById('echeck_form').style.visibility = 'hidden';
	if (document.getElementById('echeck_form')) document.getElementById('echeck_form').style.display = 'none';	 
 }
 else
 {
   //alert("test");
	if (document.getElementById('echeck_form')) document.getElementById('echeck_form').style.visibility = 'visible';
	if (document.getElementById('echeck_form')) document.getElementById('echeck_form').style.display = 'block';
	
	
	if (document.getElementById('credit_card_form')) document.getElementById('credit_card_form').style.visibility = 'hidden';
	if (document.getElementById('credit_card_form')) document.getElementById('credit_card_form').style.display = 'none';	 
 }
 
 
 
}

function add_image_show()
{
document.getElementById('div_thumb').style.visibility = 'visible';
document.getElementById('div_thumb').style.display = 'block';
document.getElementById('img_thumb').src = document.getElementById('photo_file').value	
}

function add_image_show1()
{
document.getElementById('div_thumb').style.visibility = 'visible';
document.getElementById('div_thumb').style.display = 'block';
document.getElementById('img_thumb').src = document.getElementById('product_file').value	
}

function add_image_show2()
{
  document.getElementById('div_thumb').style.visibility = 'visible';
  document.getElementById('div_thumb').style.display = 'block';
  document.getElementById('img_thumb').src = document.getElementById('freeproduct_file').value	
}


