function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return "";
	}

	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function emailCheck (emailStr) {

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\'\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="('[^']*')"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
	    return false
	}	

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    for (var i=1;i<=4;i++) {
	    	if (IPArray[i]>255) {
		   return false
	    	}
    	    }
	    return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	    return false
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	domArr[domArr.length-1].length>3) {
	   return false
	}

	if (len<2) {
	   return false
	}	

	return true;
}

function checkPhone(field) {
	phoneRegex1 = /^\d{2}-\d{3}-\d{4}$/;
	phoneRegex2 = /^\d{2}-\d{3}-\d{3}$/;
	//phoneRegex3 = /^\d{1}-\d{3}-\d{3}$/;
	phoneRegex4 = /^\d{1}-\d{3}-\d{4}$/;
	if (!field.match(phoneRegex1) && !field.match(phoneRegex2) && !field.match(phoneRegex4)) {
		return false;
	}
	return true;
}

function check_store_form(id, defaultText){	
	
	htmlElement = document.getElementById(id);

	if (!Trim(htmlElement.value) || (Trim(htmlElement.value) == "U heeft nog geen zoekopdracht ingevoerd!")
		 || (Trim(htmlElement.value) == defaultText)) {
		htmlElement.value = "U heeft nog geen zoekopdracht ingevoerd!";
		htmlElement.select();

		return false;
	} else {
		return true;
	}
	
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function setPageHeight(){
	var height;
	var arrayPageSize = getPageSize();
	if ($("#left_column").height() < (arrayPageSize[1] - 26)) {
		$("#left_column").height((arrayPageSize[1] - 26));		
	}
}

function inicRepairTabMenu(){
	$("#store_change_bg div.store_change").hover(function(){
			$(this).addClass("selected_tabmenu");
		},
		function(){
			$(this).removeClass("selected_tabmenu");
		}
	);
	$("#store_change_bg div.store_change").each(function(){
		if($(this).attr("selected")){
			var smethod=$(this).attr("selected");
			selectRepairTab($(this).attr("id"));
		}	
		if(smethod=="hover"){
			$("#store_change_bg div").hover(function(){
				select_tab($(this).attr("id"));
			})
		}
		else{
			$("#store_change_bg div.store_change").click(function(){
				selectRepairTab($(this).attr("id"));
			})
		}
	})
}

function selectRepairTab(id){
	var head_obj="#store_change_bg div#"+id;
	var body_obj="#stores div#store"+id;
	$("#store_change_bg div").removeClass("selected_tabmenu");
	$(head_obj).addClass("selected_tabmenu");
	$("#stores div.store_box").hide();
	$(body_obj).fadeIn("slow");
}

function other_store_select_in_repair(id){
	var body_obj="#stores div#storeid"+id;
	$("#stores div.store_box").hide();
	$(body_obj).fadeIn("slow");
}

function inicTabMenu(){
	$("#store_change_bg div").hover(function(){
			$(this).addClass("selected_tabmenu");
		},
		function(){
			$(this).removeClass("selected_tabmenu");
		}
	);
	$("#store_change_bg div").each(function(){
		if($(this).attr("selected")){
			var smethod=$(this).attr("selected");
			select_tab($(this).attr("id"));
		}	
		if(smethod=="hover"){
			$("#store_change_bg div").hover(function(){
				select_tab($(this).attr("id"));
			})
		}
		else{
			$("#store_change_bg div").click(function(){
				select_tab($(this).attr("id"));
				var i = 1 * ($(this).attr("id").substr(2));
				myclick(i);
			})
		}
	})
}

function select_tab(id){
	var head_obj="#store_change_bg div#"+id;
	var body_obj="#stores div#store"+id;
	$("#store_change_bg div").removeClass("selected_tabmenu");
	$(head_obj).addClass("selected_tabmenu");
	$("#stores div.store_box").hide();
	$(body_obj).fadeIn("slow");
}

function select_store_in_sales(id){
	var body_obj="#stores div#storeid"+id;
	$("input#store_id").val(id);
	$('a.lightbox'+id).lightBox();
	$("#stores div.store_box").hide();
	$(body_obj).fadeIn("slow");
}

var myslideshow;

function slideShowInic(){
	myslideshow = $('div.slider_pic').slideshow({
		width:581,     // width in px
		height:190,    // height in px
		index:0,       // start from frame number N
		time:9000,     // time out beetwen (ms)
		title:false,   // show title
		panel:true,    // show controls panel
		loop:true,    // stop looping
		 
		effect:'fade',      // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, zoomTL, zoomBR, growX, growY, random
		effecttime:2500,      // aviable fast,slow,normal and any valid fx speed value
		nextclick:false,       // bind content click next slide
		playframe:false,       // show frame "Play Now!"
		imgresize:true,       // resize image to slideshow window
		help:'',
		 
		controls :{         // show/hide controls elements
			'hide':false,   // show controls bar on mouse hover
			'first':false,  // goto first frame
			'prev':false,   // goto previouse frame (if it first go to last)
			'play':false,    // play slideshow
			'next':false,   // goto next frame (if it last go to first)
			'last':false,   // goto last frame
			'help':false,   // show help message
			'counter':false  // show slide counter
		}
	});
	myslideshow.playSlide();
}

var headerslideshow;

function headerslideShowInic(){
	headerslideshow = $('div.header_slider_pic').slideshow({
		width:807,     // width in px
		height:91,    // height in px
		index:0,       // start from frame number N
		time:10000,     // time out beetwen (ms)
		title:false,   // show title
		panel:false,    // show controls panel
		loop:true,    // stop looping
		 
		effect:'fade',      // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, zoomTL, zoomBR, growX, growY, random
		effecttime:2000,      // aviable fast,slow,normal and any valid fx speed value
		nextclick:false,       // bind content click next slide
		playframe:false,       // show frame "Play Now!"
		imgresize:true,       // resize image to slideshow window
		help:'',
		 
		controls :{         // show/hide controls elements
			'hide':false,   // show controls bar on mouse hover
			'first':false,  // goto first frame
			'prev':false,   // goto previouse frame (if it first go to last)
			'play':false,    // play slideshow
			'next':false,   // goto next frame (if it last go to first)
			'last':false,   // goto last frame
			'help':false,   // show help message
			'counter':false  // show slide counter
		}
	});
	headerslideshow.playSlide();
}


function selectSlideMenuTab(id){

	var menu_obj="#main_slider_menu_bg div#slide_menu"+id;
	var menus_obj="#main_slider_menu_bg div.slide_menu";
	
	$(menus_obj).removeClass("main_slider_menu_activ");
	$(menus_obj).addClass("main_slider_menu");
	
	$(menu_obj).addClass("main_slider_menu_activ");
	
	var tabs_obj="#slider_menu_content_box div.slider_content_box";
	var tab_obj="#slider_menu_content_box div#slider_menu_content_box"+id;
	$(tabs_obj).hide();
	$(tab_obj).fadeIn("slow");
	
}

function selectSlideNewsTab(id){

	var menu_obj="#change_bg div#slide_menu"+id;
	var menus_obj="#change_bg div.slide_menu";
	
	$(menus_obj).removeClass("main_slider_menu_activ");
	$(menus_obj).addClass("main_slider_menu");
	
	$(menu_obj).addClass("main_slider_menu_activ");
	
	var tabs_obj="#slider_menu_content_box div.slider_content_box";
	var tab_obj="#slider_menu_content_box div#slider_menu_content_box"+id;
	$(tabs_obj).hide();
	$(tab_obj).fadeIn("slow");
	
}

function selectSlideMenu(id){

	var menu_obj="#main_slider_menu_bg div#slide_menu"+id;
	var menu_end_obj="#main_slider_menu_bg div#slide_menu_end"+id;
	var menus_obj="#main_slider_menu_bg div.slide_menu";
	var menus_end_obj="#main_slider_menu_bg div.slide_menu_end";
	
	$(menus_obj).removeClass("main_slider_menu_activ1");
	$(menus_obj).addClass("main_slider_menu1");
	$(menus_end_obj).removeClass("main_slider_menu_activ_right");
	$(menus_end_obj).removeClass("main_slider_menu_activ_left");
	$(menus_end_obj).addClass("main_slider_menu_left_right");
	
	$(menu_obj).addClass("main_slider_menu_activ1");
	$(menu_end_obj).addClass("main_slider_menu_activ_right");
	
	if (id != 0) {
		var menu_prev_obj="#main_slider_menu_bg div#slide_menu_end"+(id-1);
		$(menu_prev_obj).addClass("main_slider_menu_activ_left");
	}
	
}

function show_lc(param_img,param_content){  
	if (document.getElementById(param_content).style.display=="none"){
		document.getElementById(param_img).src = "/images/tree_minus.gif";
		$("#"+param_content).show("normal");
	} else {
		document.getElementById(param_img).src = "/images/tree_plus.gif";
		$("#"+param_content).hide("normal");
	}
}

function show_product_spec(){  
	if ($("#product_specs").css('display') == "none"){
		$("#product_specs_pic").attr('src', '/images/minus-more-spec.jpg');
		$("#product_specs_pic").attr('alt', '-');
		$("#product_specs").show("normal");
	} else {
		$("#product_specs_pic").attr('src', '/images/plus-more-spec.jpg');
		$("#product_specs_pic").attr('alt', '+');
		$("#product_specs").hide("normal");
	}
}

function closeFunc(){
	$("#slidePopUp").slideUp();		
	$.cookie('wgsPopUp', '1');
}


