function equaliseheight(node,node2){
	if(!document.getElementById('n1')) return false;
n1=document.getElementById(node);
n2=document.getElementById(node2);

if(n1.offsetHeight>n2.offsetHeight){
	n2.style.height=n1.offsetHeight+"px";
}
	
}

function imageSwapper(){
	//alert('running');
	
	if(!document.getElementById('mainProdImage')) return false;
	if(document.getElementById('prodGallery')){
	var imgList=document.getElementById('prodGallery')
		//var	mainImg=document.getElementById('mainProdImage');					   
			var imgLinks=imgList.getElementsByTagName('a');
			for (var i=0;i<imgLinks.length;i++){
			
			imgLinks[i].onclick = function ()
                                {	
									
									var	mainImg=document.getElementById('mainProdImage');
									//alert(mainImg.getAttribute('src'));
									//alert(this.getAttribute('href'));
									
									swap_img=mainImg.getAttribute('src');
									//new_img=this.getAttribute('href');
									
                                    mainImg.setAttribute('src',this.getAttribute('href'));
									mainImg.parentNode.setAttribute('href',mainImg.getAttribute('src'));
									//mainImg.parentNode.setAttribute('href',new_img);
									//alert(swap_img);
									
									this.setAttribute('href',swap_img);
									this.firstChild.setAttribute('src',swap_img);
                                        //if(this.protocol=="file:"){
									return false;


                                }
			}
}
}

function popupLinks(){

// Tkes links with popupclasss and add popup code //

// onload // popupLinks(); //	

if(!document.getElementById)return false;

var aLinks=document.getElementsByTagName('a');

for (var i=0;i<aLinks.length;i++)

	{

        if (aLinks[i].className.search('popup')!= -1)

                        {

                        aLinks[i].onclick = function ()

							{

                                var linktype=this.getAttribute('href');

                                var linktype_array=linktype.split(".");

                                var linkex=linktype_array[linktype_array.length-1].toLowerCase();                                                                               

                                if(linkex=='ipx'){/* do something*/ }                                                

                                        else{window.open(this.getAttribute('href'),'');}

                                return false;

                             }

                                

                        }

		

     	aLinks[i].onkeypress = aLinks[i].onclick;

	}

// end popup links //	

}





function loadfunctions(){
	imageSwapper();
	//equaliseheight('nav','main');
	popupLinks();

	
}
window.onload=loadfunctions;

$(document).ready(function(){ 
// setup so mens are hidden;	
$("#womenLink").addClass('sgactive');
$("#mensStyle").css('display','none');


	$("#womenLink").click(function(){
		//alert('tracking');				
			$(".sgactive").removeClass('sgactive');
			$(this).addClass('sgactive');
			$("#mensStyle").css('display','none');
			$("#womensStyle").css('display','block');
			$("#email").focus();
		return false;					
	}); 
				
			
	$("#menLink").click(function(){		
	//alert('tracking');			
			$(".sgactive").removeClass('sgactive');
			$(this).addClass('sgactive');
			$("#mensStyle").css('display','block');
			$("#womensStyle").css('display','none');
			$("#email").focus();
		return false;						
	}); 
		
		
	$(".thumbImg").click(function(){
		//alert('running');		
				$newURl=$(this).children('a').attr('href');
				$new1=$(this).children('.item1').html();
				$new2=$(this).children('.item2').html();
				$new3=$(this).children('.item3').html();
				//alert($new1);
				//alert($newURl);			
				$("#mainSImg").children('img').attr("src",$newURl);	
				$("#mainSImg").find('.item1').html($new1);
				$("#mainSImg").find('.item2').html($new2);
				$("#mainSImg").find('.item3').html($new3);
				return false;						
	});
	
			//alert($(this).attr('href'));
			//$(".sgactive").removeClass('sgactive');
			//$(this).addClass('sgactive');
				
			//$('#sgimage-main .img-wrapper.css').css('background','url('+$('#sgimage-img').attr("src")+') no-repeat center center');
			//$newImg=$(this).attr('href');
			
			//$('#sgimage-img').fadeTo("slow", 0, function(){			
			//	$('#sgimage-img').attr("src",$newImg);			
				//$('#sgimage-img').fadeTo("slow", 1);
			//}); 
	
	
	
	/* This is basic - uses default settings */
	
	$("a#ssimage").fancybox();
	
	/* Using custom settings */
	
	
	

	
	 
 
 });
