
// buy check
validatePurchase = function (groupNameForErrorMsg) { //groupNameForErrorMsg optionally passed for options on buy button
var msgOptions='';
var msgPrices='';

if (document.getElementById('PRODoption').value=='not_selected'){
if (groupNameForErrorMsg)   msgOptions =  groupNameForErrorMsg;
if (!groupNameForErrorMsg)  msgOptions = 'Product options.' ;
document.getElementById('optionsWrapper').style.borderColor='#ff0000';
}

if (document.getElementById('priceSelector').value=='not_selected'){
 msgPrices =  'Colours/Styles.' ;//Pricing
 document.getElementById('pricesWrapper').style.borderColor='#ff0000';
} 

if (msgOptions!='' || msgPrices!='' ){
	if (msgOptions !='' &&  msgPrices =='') alert('Please select from the ' + msgOptions)
	if (msgPrices  !='' &&   msgOptions=='') alert('Please select from the ' + msgPrices)
//	if (msgPrices  !='' &&   msgOptions !='') alert('Please select from the ' + msgOptions + ' and ' + msgPrices)
	if (msgPrices  !='' &&   msgOptions !='') alert('Please select from both of the options.')
	return false;
}

} 

 

// buy check


//images popup
var currentImage=1;
var currentArrayPosition=1;
function showLargeImage(id){
win=window.open('/product-images/' + id + '/' + currentArrayPosition	 + '.htm','details','width=300,height=200');
win.focus();
}

function swapImage(id,picNum,arrayPosition){
currentImage=picNum;
currentArrayPosition=arrayPosition; // used to open correct in array
theId=$('idForMedia').value; //hdn on P_D page for id selected
new Ajax.Updater('mediaWrapper','media/_detailsImages.inc.php?id='+theId + '&picNum=' + picNum ,{
evalScripts:true
}) 
  

}
//images


// swap back to  images
function showImages(){ 
theId=$('idForMedia').value; //hdn on P_D page for id selected
new Ajax.Updater('mediaWrapper','media/_detailsImages.inc.php?id='+theId  ,{
evalScripts:true
 //,onLoading: $('mediaWrapper').innerHTML='<div  style="text-align:center;padding-top:60px"><img src="./_ajax/loading1.gif"   /></div>'
}) 
} 

function playVideo(vidNum){
theId=$('idForMedia').value; //hdn on P_D page for id selected
//new Effect.Opacity( 'mediaWrapper',  {duration:0.8, from:0, to:1.0} ); 
new Ajax.Updater('mediaWrapper','media/_detailsVideo.inc.php?id='+theId+'&vidNum='+vidNum ,{
evalScripts:true
})  
} 

 

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;


