function playVideo(vidName,count,clicked,folder){
	for(i=0;i<count;i++){
		var spec = "sub_"+i;
		document.getElementById("sub_"+i).style.background = 'url(/images/videoConsole.gif)';
		if(spec == clicked){
			document.getElementById("sub_"+i).style.background = 'url()';
			document.getElementById("sub_"+i).style.backgroundColor = '#FFE475';
		}
	}
	document.getElementById('videocontainer').innerHTML ='<EMBED SRC="" WIDTH="338" HEIGHT="153" NOJAVA=true CONTROLS=ImageWindow CONSOLE=one AUTOSTART="true" Showcontrols="false">';
	document.getElementById('videocontainer').innerHTML ='<PARAM NAME="CONTROLS" VALUE="ImageWindow"><EMBED SRC="/'+folder+'/videos/'+vidName+'" WIDTH="338" HEIGHT="213" NOJAVA=true CONTROLS=ImageWindow CONSOLE=one AUTOSTART="1" showcontrols="0" showtracker="0" showdisplay="0" showstatusbar="0">';
}


function playVideo2(vidName,count,clicked,folder){
	for(i=0;i<count;i++){
		var spec = "sub_"+i;
		document.getElementById("sub_"+i).style.background = 'url(/images/videoConsole.gif)';
		if(spec == clicked){
			document.getElementById("sub_"+i).style.background = 'url()';
			document.getElementById("sub_"+i).style.backgroundColor = '#FFE475';
		}
	}
	document.getElementById("playerFrame").src = "/"+folder+"/vid.php?v=" + vidName;
	return false;

}

function validateNewsletter(NAME,EMAIL){
	var root=document.newsletter;
	var name=root.name;
	var email=root.email;
	if(name.value==NAME){
		alert("Please enter your full name.");
		name.focus();
		return false;
	}
	if(email.value==EMAIL){
		alert("Please enter an email address.");
		email.focus();
		return false;

	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.focus();
		return false;
	}
}

function playVideoAuto(vidName){
	//alert(vidName);
	document.getElementById("videocontainer").innerHTML ='<PARAM NAME="CONTROLS" VALUE="ImageWindow"><EMBED SRC="/tv/videos/'+vidName+'" WIDTH="338" HEIGHT="213" NOJAVA=true CONTROLS=ImageWindow CONSOLE=one AUTOSTART="1" showcontrols="0" showtracker="0" showdisplay="0" showstatusbar="0">';
}

function printArrow(count,clicked,langId){
	for(i=0;i<count;i++){
		var spec = "td_"+i;
		document.getElementById('td_'+i).innerHTML = '';
		if(spec == clicked){
			if(langId == 1){
				document.getElementById('td_'+i).innerHTML = '<img src="/images/en/cursorArrow.gif" />';
			}else{
				document.getElementById('td_'+i).innerHTML = '<img src="/images/ar/cursorArrow.gif" />';
			}

		}
	}
}

function setNewsLetter(){
	//alert('jean');
	var state = document.getElementById('newsletterPop').style.visibility;
	if(state == "hidden"){
		document.getElementById('newsletterPop').style.visibility="visible";
	}else{
		document.getElementById('newsletterPop').style.visibility="hidden";
	}
}

function validateFaq(){
	var root=document.submit_faq;
	var email = root.email;
	if(email.value == ''){
		alert("Please insert your email");
		root.email.focus();
		return false;
	}

	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag=email.value.match(pattern);
	if(!flag){
		alert("please insert a valid email address");
		root.email.focus();
		return false;
	}

	question1 = root.question.value;
	if(question1==''){
		alert('Please provide a question.');
		root.question.focus();
		return false;
	}
	return true;
}

function toggle(obj) {
	// Moz. or IE
	var sibling=(obj.nextSibling.nodeType==3)? obj.nextSibling.nextSibling : obj.nextSibling;
	// hide or show
	if(sibling.style.display=='' || sibling.style.display=='block') {
		sibling.style.display='none';
		obj.firstChild.firstChild.data='+ ';
	}
	else {
		sibling.style.display='block';
		obj.firstChild.firstChild.data='- ';
	}
}

function initCollapse() {

	var oDT=document.getElementById('version').getElementsByTagName('dt');
	for (var i=0; i < oDT.length; i++) {
		oDT[i].onclick=function() {toggle(this)};
		var oSpan=document.createElement('span');
		var sign=document.createTextNode('');
		oSpan.appendChild(sign);
		oDT[i].insertBefore(oSpan, oDT[i].firstChild);
		oSpan.style.fontFamily='tahoma';
		oSpan.style.paddingRight='3px';
		oDT[i].style.cursor='pointer';
		toggle(oDT[i]);
	}
	oDT=null;
}


var Timer;
function ScrollLeft()
{
	Timer = setInterval("document.getElementById('PANORAMA').scrollLeft -= 3", 15);
}
function ScrollRight()
{
	Timer = setInterval("document.getElementById('PANORAMA').scrollLeft += 3", 15);
}

function checkUncheckAll(theElement) {
	//documentation for this script at http://www.shawnolson.net/a/693/
	var theForm = theElement.form, z = 0;
	while (theForm[z].type == 'checkbox') {

		theForm[z].checked = theElement.checked;
		z++;
	}
}

function popImage(imageURL,imageTitle){
	defaultWidth  = 100;
	defaultHeight = 100;
	//alert(imageURL+imageTitle);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"></body></html>');
			close();
		}
}


function validate_guestbook()
{

	var root = document.guestbook;
	var name = root.namee;
	var email = root.email;
	var comment = root.comment;
	var vcode=root.vcode;

	if(name.value == ''){
		alert("Please insert your name");
		root.namee.focus();
		return false;
	}

	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag=email.value.match(pattern);
	if(!flag){
		alert("please insert a valid email address");
		root.email.focus();
		return false;
	}
	if(comment.value == ''){
		alert("Please insert a comment");
		root.comment.focus();
		return false;
	}

	if(vcode.value == ''){
		alert("Please insert the visual code");
		root.vcode.focus();
		return false;
	}
	return true;
}

function validateShare()
{

	var root = document.share;
	var title = root.title;
	var descr = root.description;
	var image = root.image;
	var vcode =  root.vcode;

	if(title.value == ''){
		alert("Please insert the title");
		title.focus();
		return false;
	}

	if(descr.value == ''){
		alert("Please insert the description");
		descr.focus();
		return false;
	}

	if(image.value == ''){
		alert("Please browse for an image");
		image.focus();
		return false;
	}

	if(vcode.value == ''){
		alert("Please insert the visual code");
		vcode.focus();
		return false;
	}
	return true;
}


function validateTopic(){
	var root = document.topic_suggest;
	var title = root.topic_title;
	var msg = root.topic_description;

	if(title.value == ''){
		alert("Please insert your topic title");
		title.focus();
		return false;
	}

	if(msg.value == ''){
		alert("Please insert your topic description");
		msg.focus();
		return false;
	}
	return true;
}

function validateNewsletter(){
	var root=document.newsletter;
	var name=root.name;
	var email=root.email;
	if(name.value=='name' || name.value==''){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value=='email' || email.value==''){
		alert('Please enter an email address.');
		email.focus();
		return false;

	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
}
function validatePass(){
	var root=document.passw;
	var pass=root.password;
	if(pass.value==''){
		alert('Please enter your PASSWORD.');
		pass.focus();
		return false;
	}
	return true ;
}



function previewCatImage(imageURL,imageTitle,titleNews){
	//alert(title);
	defaultWidth  = 500;
	defaultHeight = 500;

	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height)+30;');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
			writeln('<table border="0" cellpadding="0" cellspacing="0" width="100"><tr><td align="center" style="font-size:12px;color: #676767;font-family:arial;font-weight:bold;">'+titleNews+'</td></tr><tr><td></td></tr><tr><td><img name="Image" src='+imageURL+' style="display:block"></td></tr></table></body></html>');
			close();
		}
}

function validateContact(){
	var root=document.contactus;
	var destination=root.destination;
	var name=root.namee;
	var email=root.email;
	var subject=root.subject;
	var message=root.message;
	var vcode=root.vcode;
	
	if(destination.value==''){
		alert('Please select the destination email.');
		destination.focus();
		return false;
	}	
	
	if(name.value==''){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==''){
		alert('Please enter an email address.');
		email.focus();
		return false;

	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}

	if(subject.value==''){
		alert('Please provide your subject.');
		subject.focus();
		return false;
	}
	if(message.value==''){
		alert('Please provide your message.');
		message.focus();
		return false;
	}
	if(vcode.value==''){
		alert('Please provide the visual code.');
		vcode.focus();
		return false;
	}
}
function clearContactForm(){
	if(confirm('Are you sure you want to clear the form?')){
		var root=document.contactus;
		var name=root.namee;
		var email=root.email;
		var subject=root.subject;
		var message=root.message;
		name.value = '';
		email.value = '';
		subject.value = '';
		message.value = '';
	}
	return false;
}

function clearRegistrationForm(){
	if(confirm('Are you sure you want to clear the form?')){
		var root = document.register;
		var username = root.username;
		var name = root.namee;
		var email = root.email;
		var pass = root.password;
		var confirmm = root.confirmm;
		var countries = root.countries;
		var city = root.city;
		var address = root.address;
		var phone = root.phone;
		name.value = '';
		username.value = '';
		email.value = '';
		pass.value = '';
		confirmm.value = '';
		countries.value = '';
		city.value = '';
		address.value = '';
		phone.value = '';
	}
	return false;
}

function clearEditProfileForm(){
	if(confirm('Are you sure you want to clear the form?')){
		var root = document.edit_profile;
		var name = root.name;
		var email = root.email;
		var countries = root.countries;
		var city = root.city;
		var address = root.address;
		var phone = root.phone;
		name.value = '';
		email.value = '';
		countries.value = '';
		city.value = '';
		address.value = '';
		phone.value = '';
	}
	return false;
}

function validateRegistration(){
	var root = document.register;
	var username = root.username;
	var name = root.namee;
	var email = root.email;
	var pass = root.password;
	var confirm = root.confirmm;
	var countries = root.countries;
	var city = root.city;
	var address = root.address;
	var phone = root.phone;

	if(username.value==""){
		alert("Please enter your Username");
		username.focus();
		return false;
	}
	if(name.value==""){
		alert("Please enter your Full name");
		name.focus();
		return false;
	}
	if(email.value==""){
		alert("Please enter your email address");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	if(pass.value==""){
		alert("Please enter your Password");
		pass.focus();
		return false;
	}
	if(pass.value.length < 6){
		alert("Please enter a password greater than 6 characters");
		pass.focus();
		return false;
	}
	if(confirm.value==""){
		alert("Please confirm your password");
		confirm.focus();
		return false;
	}
	if(pass.value != confirm.value){
		alert("The password and it's confirmation do not match");
		confirm.focus();
		return false;
	}

	if(address.value==""){
		alert("Please insert your address");
		address.focus();
		return false;
	}
	if(city.value==""){
		alert("Please provide your city");
		city.focus();
		return false;
	}
	if(countries.value==""){
		alert("Please provide your country");
		countries.focus();
		return false;
	}

	if(phone.value==""){
		alert("Please enter your Phone number");
		phone.focus();
		return false;
	}
	/*	if(isNaN(phone.value)){
	alert("Phone number should be numeric only");
	phone.focus();
	return false;
	}*/
	return true;
}

function validateUPDprofile(){
	var root = document.edit_profile;
	var name = root.name;
	var email = root.email;
	var countries = root.countries;
	var city = root.city;
	var address = root.address;
	var phone = root.phone;

	if(name.value==""){
		alert("Please enter your Full name");
		name.focus();
		return false;
	}
	if(email.value==""){
		alert("Please enter your email address");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	if(countries.value==""){
		alert("Please provide your country");
		countries.focus();
		return false;
	}
	if(city.value==""){
		alert("Please provide your city");
		city.focus();
		return false;
	}
	if(address.value==""){
		alert("Please insert your address");
		address.focus();
		return false;
	}
	if(phone.value==""){
		alert("Please enter your Phone number");
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		alert("Phone number should be numeric only");
		phone.focus();
		return false;
	}
	return true;
}
function previewColl(id)
{
	window.open("/collections/more.php?id="+id,"view_product","width=280,height=390,status=0,toolbar=0,scrollbars=1,history=0,left=100,top=100");
	return false;
}

function validChars(e,goods,field,max) {

	var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();

	if (goods.indexOf(keychar) != -1)
	return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
	return true;

	return false;
}

function ValidatePassword(){
	var root =document.password;
	var email = root.email;
	var username = root.username;
	if(username.value==""){
		alert("Please enter your username");
		username.focus();
		return false;
	}
	if(email.value==""){
		alert("Please enter your email");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	return true;
}

function validateChange(){
	var root = document.change_pass;
	var old = root.old;
	var new_pass = root.new_pass;
	var confirm_pass = root.confirm_pass;

	if(old.value==""){
		alert("Please enter your old Password");
		old.focus();
		return false;
	}
	if(new_pass.value==""){
		alert("Please enter your new Password");
		new_pass.focus();
		return false;
	}
	if(confirm_pass.value==""){
		alert("Please Confirm your new Password");
		confirm_pass.focus();
		return false;
	}
	if(new_pass.value != confirm_pass.value){
		alert("The Password and it's Confirmation Do not Match.");
		confirm_pass.focus();
		return false;
	}
	return true;
}

function validateLogin(USERNAME,PASSWORDD){
	var root = document.login;
	var name = root.name;
	var pass = root.password;

	if(name.value==""){
		alert("Please enter your Username");
		name.focus();
		return false;
	}

	if(name.value==USERNAME){
		alert("Please enter your Username");
		name.focus();
		return false;
	}
	if(pass.value==""){
		alert("Please enter your Password");
		pass.focus();
		return false;
	}
	if(pass.value==PASSWORDD){
		alert("Please enter your Password");
		pass.focus();
		return false;
	}
	return true;
}

function PlayClip(){
	document.video1.DoPlay();
	return false;
}

function stopClip(){
	document.video1.DoStop();
	return false;
}

function goforward(){

	var lenght2 = document.video1.GetLength();
	var postion = document.video1.GetPosition();
	var mustbeGreater = parseInt(postion) + 5000;
	if( (parseInt(postion) > 0) && (parseInt(lenght2) > 0) && (mustbeGreater < lenght2)){
		document.video1.SetPosition(mustbeGreater);
		return false;
	}
	else{
		return false;
	}
}

function gobackwards(){
	var lenght2 = document.video1.GetLength();
	var postion = document.video1.GetPosition();
	var mustbelower = parseInt(postion) - 5000;
	if( (parseInt(postion) > 5000) && (parseInt(lenght2) > 0) && (mustbelower > 0)){
		document.video1.SetPosition(mustbelower);
		return false;
	}
	else{
		return false;
	}
}

