//--------EQUAL HEIGHTS---------//
$(function(){ $('#content_border').equalHeights(true); });
$(function(){ $('.offers').equalHeights(true); });
$(function(){ $('.brandOffers').equalHeights(true); });
$(function(){ $('.cartSteps').equalHeights(true); });
$(function(){ $('.cartDetails').equalHeights(true); });
//--------END EQUAL HEIGHTS---------//


//--------MOUSEOVER FADE EFFECT---------//
$(document).ready(function(){
$("#content_box_left").hover(function(){
$("#content_box_left").fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
$("#content_box_right").fadeTo("fast", 0.45); // This should set the opacity to 100% on hover
},function(){
$("#content_box_left").fadeTo("fast", 1.0); // This should set the opacity back to 60% on mouseout
});
});


$(document).ready(function(){
$("#content_box_right").hover(function(){
$("#content_box_right").fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
$("#content_box_left").fadeTo("fast", 0.45); // This should set the opacity to 100% on hover
},function(){
$("#content_box_right").fadeTo("fast", 1.0); // This should set the opacity back to 60% on mouseout
});
});
//--------END MOUSEOVER FADE EFFECT---------//

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function isNumeric(inputVal) {
     if (isNaN(parseFloat(inputVal))) {
        
          return false;
     }
     return true
}

function validateEmail(fld) {
	

    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
			
			
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\&\=\#\;\:\\\"\[\]]/ ;
		var error_mail = 0;
		
    if (tfld.value == "") {
   		
		error_mail = 1;
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
	
		error_mail = 1;
    } else if (tfld.match(illegalChars)) {
		error_mail = 1;	
    } else {
				error_mail = 0;
    }
    return error_mail;
}

function ShowErrorClass(id)
{ var elem = document.getElementById(id);
	elem.className = "brd_error";
}

function HideErrorClass(id)
{ var elem = document.getElementById(id);
	elem.className = "brd";
}

function trim(stringToTrim)
{ 
return stringToTrim.replace(/^\s+|\s+$/g,"");}

function changeClass(elem, classElem)
{
	if (document.getElementById(elem) != null)
	{document.getElementById(elem).className = classElem;}
}

function fbs_click(u) {
		if (u==''){
			u=location.href;
		}
		t=document.title;
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
		return false;
}

function showDiv_display(pass) { 

var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.display="block"; 
} 
} 
}

function hideDiv_display(pass) { 

var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.display="none"; 
} 
} 
}

function showElem_display(pass) { 
if (document.getElementById(pass)!=null) 
document.getElementById(pass).style.display="block"; 
}

function hideElem_display(pass) { 
if (document.getElementById(pass)!=null)  
document.getElementById(pass).style.display="none"; 
}

function open_popup(theURL) { //v2.0
 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width=620,height=520');
}

function open_popup_wide(theURL) { //v2.0
 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width=760,height=520');
}

// product select functions
function selectColor(color, urlSmall, urlBig){
	
	var divs=document.getElementsByTagName("div");

	for(var i=0;i<divs.length;i++){
		if (divs[i].id.indexOf("divColor_",0) != -1) {
			hideElem_display(divs[i].id);
		}
	}

	var ahref=document.getElementsByTagName("a");

	for(var i=0;i<ahref.length;i++){
		if (ahref[i].id.indexOf("a_divColor_",0) != -1) {
			document.getElementById(ahref[i].id).className="";
		}
	}
	showElem_display('divColor_'+color);
	document.getElementById('a_divColor_'+color).className="active";
	
	if (urlSmall != '' && urlBig != '') {
		document.getElementById('urlSmall').src=urlSmall;
		document.getElementById("urlBig").href = urlBig;
	}
	
	$(".size").show();
}

function selectColorAndOpid(opid, regularPriceDimensions, discountPriceDimensions, savePriceDimensions, hasDiscountDimensions, color, urlSmall, urlBig){
	
	var divs=document.getElementsByTagName("div");

	for(var i=0;i<divs.length;i++){
		if (divs[i].id.indexOf("divColor_",0) != -1) {
			hideElem_display(divs[i].id);
		}
	}

	var ahref=document.getElementsByTagName("a");

	for(var i=0;i<ahref.length;i++){
		if (ahref[i].id.indexOf("a_divColor_",0) != -1) {
			document.getElementById(ahref[i].id).className="";
		}
	}
	showElem_display('divColor_'+color);
	document.getElementById('a_divColor_'+color).className="active";
	
	if (urlSmall != '' && urlBig != '') {
		document.getElementById('urlSmall').src=urlSmall;
		document.getElementById("urlBig").href = urlBig;
	}
	
	document.getElementById('opid_selected').value=opid;
	
	if (hasDiscountDimensions == 1 )
	{
		document.getElementById('regPriceSpan').innerHTML =regularPriceDimensions;
		document.getElementById('yourPriceSpan').innerHTML =discountPriceDimensions;
		document.getElementById('discountSpan').innerHTML =savePriceDimensions;
	}
	else
	{	
		document.getElementById('yourPriceSpan').innerHTML =regularPriceDimensions;
	}
}

function selectAdditional(urlSmall, urlBig){
	
	if (urlSmall != '' && urlBig != '') {
		document.getElementById('urlSmall').src=urlSmall;
		document.getElementById("urlBig").href = urlBig;
	}
}

function selectOpid(opid, regularPriceDimensions, discountPriceDimensions, savePriceDimensions, hasDiscountDimensions){
	

var ahref=document.getElementsByTagName("a");

for(var i=0;i<ahref.length;i++){
	if (ahref[i].id.indexOf("opid_",0) != -1) {
		if (document.getElementById(ahref[i].id).className != 'off') {
			document.getElementById(ahref[i].id).className="";
		}
	}
}
if (document.getElementById('opid_'+opid).className != 'off') {
	document.getElementById('opid_'+opid).className="active";
}

	document.getElementById('opid_selected').value=opid;
	
	if (hasDiscountDimensions == 1 )
	{
		document.getElementById('regPriceSpan').innerHTML =regularPriceDimensions;
		document.getElementById('yourPriceSpan').innerHTML =discountPriceDimensions;
		document.getElementById('discountSpan').innerHTML =savePriceDimensions;
	}
	else
	{	
		document.getElementById('yourPriceSpan').innerHTML =regularPriceDimensions;
	}
}


function AddToCart(pid, ptype)
{
	var opid = document.getElementById('opid_selected').value;
	
	if (pid == '' || pid == 0 || pid == null || opid == 0 || opid == '' || opid == null){
		
		showDiv_display('divSelectError');
	}
	else
	{
    var sLink='cart_add.asp?pid=' + pid + '&ptype='+ ptype +'&opid=' + opid;
		
    document.location.href=sLink;
	}
	
}

function open_page_kredit(credit, spec, payment) {
	
	var nbr_install = 0;
	
	if (payment == 'card') {
		var nbr_install = document.getElementById('install_card').value;
	}
	
	if (payment == 'instalments'){
		var nbr_install = document.getElementById('install_instalments').value;
	}

    var sLink='popup_kredit.asp?cn='+payment+'&credit=' + credit + '&nbr_install='+ nbr_install+'&spec='+spec+'&payment='+payment;
		
    open_popup(sLink);

}


//end product select functions

function inviteFriendEmpty(id, value, def_value){
	if(value == def_value){
		document.getElementById(id).value = '';
	}
}

function inviteFriendFill(id, value, def_value){
	if(value == ''){
		document.getElementById(id).value = def_value;
	}
}

function redirectToURl(url)
{
	document.location.href=url;
}

function showHidedivCheckbox(checkBox,divBox)
{
	
	if (document.getElementById(checkBox)!= null && document.getElementById(divBox) != null)
	{
		if (document.getElementById(checkBox).checked  == true)
		{
			showDiv_display(divBox);
		}
		else
		{
			hideDiv_display(divBox);
		}
	}
	
	
	
}
