﻿function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(title, lead,img, bgcolor, thewidth){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=bgcolor

			var output  = '<table width="100%" border="0" cellpadding="4" cellspacing="0">\n'
				output += ' <tr><td colspan="2" style="text-align:left;padding:4px"><font color="#B90000"><strong>'+title+'</strong></font></td></tr>'
				if(typeof img!="undefined")
				output += ' <tr><td style="width:72px;padding:4px;"><img width="72px" height="72px" src=' +img+ '></img></td>'
				if(title!='')
				output += ' <td valign="top" style="text-align:justify;padding:4px;padding-left:0px;"><font color="#333333">'+lead+'</font></td></tr>'
				else
				output += ' <td valign="middle" style="text-align:justify;padding:4px;padding-left:0px;"><font color="#B90000"><strong>'+lead+'</strong></font></td></tr>'
				output += '</table>'

		tipobj.innerHTML=output
		enabletip=true
		return false
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px"

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
			tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}
/*
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
*/
function fillup(){
    if (iedom){
        cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
        cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
        cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
        actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
        cross_slide2.style.left=actualwidth+slideshowgap+"px"
    }
    else if (document.layers){
        ns_slide=document.ns_slidemenu.document.ns_slidemenu2
        ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
        ns_slide.document.write(leftrightslide)
        ns_slide.document.close()
        actualwidth=ns_slide.document.width
        ns_slide2.left=actualwidth+slideshowgap
        ns_slide2.document.write(leftrightslide)
        ns_slide2.document.close()
    }
    lefttime=setInterval("slideleft()",30)
}
//window.onload=fillup

function slideleft(){
    if (iedom){
        if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
            cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
        else
            cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

        if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
            cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
        else
            cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
    }
    else if (document.layers){
        if (ns_slide.left>(actualwidth*(-1)+8))
            ns_slide.left-=copyspeed
        else
            ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
        if (ns_slide2.left>(actualwidth*(-1)+8))
            ns_slide2.left-=copyspeed
        else
            ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
    }
}
/**
 *
 * @access public
 * @return void
 **/
function ShowSubLeftMenuArtist(id,status){
    var el = document.getElementById('left_artist_intro_'+id);
    if(el != null)
    {
        el.style.display = status;
    }
    el = document.getElementById('left_artist_pics_'+id);
    if(el != null)
    {
        el.style.display = status;
    }
}

function Order_EnableButton(val){
    var el = document.getElementById('main_order_submit_button');
    if(el != null)
    {
        el.disabled = !val;
    }
}
// Removes leading whitespaces
function LTrim( value )
{
 	var re = /\s*((\S+\s*)*)/;
  	return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim( value )
{
 	var re = /((\s*\S+)*)\s*/;
  	return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim( value )
{
 	return LTrim(RTrim(value));
}
function CheckSpecialChar(str, checknull)
{
	//alert(str);
	var spChar = new Array();
	spChar[0] = "*";
	spChar[1] = "#";
	spChar[2] = "&";
	spChar[3] = "'";
	spChar[4] = "\"";
	for(var i=0; i<spChar.length;i++)
	{
		if(str.indexOf(spChar[i]) >= 0)
		{
			return true;
		}
	}
	if(checknull)
	{
		str = trim(str);
		if((str.length == 0) || (str == ' '))
		{
			return true;
		}
	}
	return false;
}

/**
 *
 * @access public
 * @return void
 **/
function MainOrderCheckInput(){
	var el = document.getElementById('mo_name');
    if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Please insert your name!Do not have  special character');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	el = document.getElementById('mo_email');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Please insert your email!Do not use special character');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	el = document.getElementById('mo_address');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Please insert your address!Do not use special character');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	el = document.getElementById('mo_phone');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, false))
    	{
        	alert('Do not use special character in your phone');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	el = document.getElementById('mo_city');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, false))
    	{
        	alert('Do not use special character in your city');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	el = document.getElementById('mo_other');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, false))
    	{
        	alert('Do not use special character in other');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	return true;
}
/**
 *
 * @access public
 * @return void
 **/
function QuickSearch_CheckInput(){
	var el = document.getElementById('rs_conditon');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Please insert condition.Do not use special character in other');
            return false;
    	}
	}
	else
	{
    	return false;
	}
	return true;
}

function Contact_CheckInput()
{
    var el = document.getElementById('yourname');

	if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Your name do not have special character and empty!');
            return false;
    	}
	}
	else
	{
    	return false;
	}

	el = document.getElementById('address');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, false))
    	{
        	alert('Your Address do not have special character!');
            return false;
    	}
	}
	else
	{
    	return false;
	}

	el = document.getElementById('phone');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, false))
    	{
        	alert('Your Phone Number do not have special character!');
            return false;
    	}
	}
	else
	{
    	return false;
	}

	el = document.getElementById('email');
	if(el != null)
	{
    	if(CheckSpecialChar(el.value, true))
    	{
        	alert('Your Email do not have special character!');
            return false;
    	}
	}
	else
	{
    	return false;
	}

}

