﻿// JScript File

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function lightboxSend_Validated(emailField, sbjFieldID)
{
    var b = false;
    b   = checkEmail(emailField);
    if ( b )
    {
        var sbjField = document.getElementById(sbjFieldID);
        
        if ( sbjField.value.toString().replace(/^\s+|\s+$/, '').length == 0 )
            return confirm('Are you sure you want to send this\nLightbox without a subject line?');
    }
    return b;
}

function lightbox_Reorder(cmbOrder, lightboxID, imageID, userControlID)
{
    var orderNo = parseInt( cmbOrder.value );
       
	Anthem_InvokeControlMethod(
		userControlID,
		'ReorderLightboxImage',
		[orderNo, lightboxID, imageID],
		function(){Anthem_PostCallBack();}    
        );
}

function lightbox_Magnify(imageID, lightboxViewID)
{
	
    //AddBackEntry('nv_LightBoxbackfromdetails',lightboxViewID + '!nv_LightBoxbackfromdetails');
    AddBackEntry('nv_LightBoximagedetails' + imageID,lightboxViewID + '!nv_LightBoximagedetails!'+ imageID);
	Anthem_InvokeControlMethod(
		lightboxViewID,
		'ViewLightboxImage',
		[imageID],
		function(){Anthem_PostCallBack();}   
        );
}

function image_Magnify(tconid, bconid, photoID)
{
    window.location.href='imagedetail.aspx?tconid=' + tconid + '&bconid=' + bconid + '&photoID=' + photoID;
}

function image_PriceCalc(tconid, bconid, photoID)
{
    window.location.href='PriceCalculator.aspx?tconid=' + tconid + '&bconid=' + bconid + '&photoID=' + photoID + "&pricecalculator=1";
    
}


function imagelb_Magnify(tconid, bconid, photoID)
{
    window.location.href='imagedetail.aspx?tconid=' + tconid + '&bconid=' + bconid + '&photoID=' + photoID;
}

function imagelb_PriceCalc(tconid, bconid, photoID)
{
    window.location.href='PriceCalculator.aspx?tconid=' + tconid + '&bconid=' + bconid + '&photoID=' + photoID + "&pricecalculator=1";
    
}


function lightbox_Delete(imageID, lightboxID, lightboxViewID)
{
	Anthem_InvokeControlMethod(
		lightboxViewID,
		'DeleteLightboxImage',
		[imageID, lightboxID],
		function(){Anthem_PostCallBack();}  
        );
}

function lightbox_Open(drpId,lightboxViewID)
{
    //alert(drpId);
    //alert(lightboxViewID);
    
    var drpObj  = document.getElementById(drpId);
    AddBackEntry('nv_lightbox_Open' + drpObj.value ,lightboxViewID + '!nv_lightbox_Open!'+ drpObj.value);
    
    Anthem_InvokeControlMethod(
		lightboxViewID,
		'OpenLightbox',
		[drpObj.value],
		function(){Anthem_PostCallBack();}  
        );
}


function resultThumb_View(imageID, resultViewID)
{
    //alert('adding image ' + imageID);
    //AddBackEntry('nv_backfromdetails',resultViewID + '!nv_backfromdetails');
    AddBackEntry('nv_imagedetails' + imageID,resultViewID + '!nv_imagedetails!'+ imageID);
	Anthem_InvokeControlMethod(
		resultViewID,
		'ShowImageDetails',
		[imageID],
		function(){Anthem_PostCallBack();}   
        );
}

function resultThumb_Add2Lightbox(imageID, resultViewID)
{   
	Anthem_InvokeControlMethod(
		resultViewID,
		'AddImageToLightbox',
		[imageID],
		function(){Anthem_PostCallBack();}    
        );
}

// ########################
// added by janaka
function resultThumb_Add2LightboxStopped(imageID, resultViewID)
{
	Anthem_InvokeControlMethod(
		resultViewID,
		'AddImageToLightboxStopped',
		[imageID],
		function(){Anthem_PostCallBack();}  
        );
}

function resultThumb_Add2ShoppingCart(imageID, resultViewID)
{
	
    
	Anthem_InvokeControlMethod(
		resultViewID,
		'AddImageToShoppingCart',
		[imageID],
		function(){Anthem_PostCallBack();} 
        );
}

// ########################
// added by janaka
function resultThumb_Add2ShoppingCartStopped(imageID, resultViewID)
{
	Anthem_InvokeControlMethod(
		resultViewID,
		'AddImageToShoppingCartStopped',
		[imageID],
		function(){Anthem_PostCallBack();}  
        );
}

function resultThumb_Add2PriceCalculatorStopped(imageID, resultViewID)
{
	Anthem_InvokeControlMethod(
		resultViewID,
		'AddImagePricecalculatorStopped',
		[imageID],
		function(){Anthem_PostCallBack();}   
        );
}


function resultThumb_PriceCalc(imageID, resultViewID)
{    
	Anthem_InvokeControlMethod(
		resultViewID,
		'PriceCalculate',
		[imageID],
		function(){Anthem_PostCallBack();}  
        );
}

function lightbox_Add2Cart(imageID, lightboxViewID)
{
	Anthem_InvokeControlMethod(
		lightboxViewID,
		'AddImageToShoppingCart',
		[imageID],
		function(){Anthem_PostCallBack();}   
        );
}

function lightbox_CalcPrice(imageID, lightboxViewID)
{

	Anthem_InvokeControlMethod(
		lightboxViewID,
		'PriceCalculate',
		[imageID],
		function(){Anthem_PostCallBack();}   
        );
}

function HelpTopicJavascriptClick(linkID,topicHeaderID)
{
    Anthem_InvokeControlMethod(topicHeaderID,"ShowTopic",[linkID],function(){Anthem_PostCallBack();});
}

function deleteShoppingItem(imageID,ctrl){
    
    Anthem_InvokeControlMethod(ctrl,'DeleteShoppingItem',[imageID]);
}

function calculateShoppingItem(imageID,ctrl){
    Anthem_InvokeControlMethod(ctrl,'CalculateShoppingItem',[imageID]);
}

function reCalculateShoppingItem(imageID,ctrl){
    Anthem_InvokeControlMethod(ctrl,'ReCalculateShoppingItem',[imageID]);
}

function calculateItemPrice(ctrl,imageID,UsageIndex,TypeOfUseIndex,imgSizeIndex, printRunIndex, insertsIndex, positionIndex, countryIndex, regionIndex, durationIndex){    
   
   // Anthem_InvokeControlMethod(ctrl,'CalulatePrice',[imageID,parseInt(UsageIndex),parseInt(TypeOfUseIndex),parseInt(imgSizeIndex),parseInt(printRunIndex), parseInt(insertsIndex), parseInt(positionIndex), parseInt(countryIndex), parseInt(regionIndex), parseInt(durationIndex)],null);
    Anthem_InvokeControlMethod(ctrl,'CalulatePrice',[imageID,parseInt(UsageIndex),parseInt(TypeOfUseIndex),parseInt(imgSizeIndex),parseInt(printRunIndex), parseInt(insertsIndex), parseInt(positionIndex), parseInt(countryIndex), parseInt(regionIndex), parseInt(durationIndex)],function(){Anthem_PostCallBack();}  );
}

function makeShoppingCart(ctrl,imageID,UsageIndex,TypeOfUseIndex,imgSizeIndex, printRunIndex, insertsIndex, positionIndex, countryIndex, regionIndex, durationIndex)
{    
    // Anthem_InvokeControlMethod("ApplicationPriceCalculator1",'testing',[ctrl]);  
    
    //Anthem_InvokeControlMethod(ctrl,'DisplayShoppingCartAndUpdate',[imageID, parseInt(UsageIndex),parseInt(TypeOfUseIndex),parseInt(imgSizeIndex),parseInt(printRunIndex), parseInt(insertsIndex), parseInt(positionIndex), parseInt(countryIndex), parseInt(regionIndex), parseInt(durationIndex)],null);
    Anthem_InvokeControlMethod(ctrl,'DisplayShoppingCartAndUpdate',[imageID, parseInt(UsageIndex),parseInt(TypeOfUseIndex),parseInt(imgSizeIndex),parseInt(printRunIndex), parseInt(insertsIndex), parseInt(positionIndex), parseInt(countryIndex), parseInt(regionIndex), parseInt(durationIndex)],function(){Anthem_PostCallBack();});
    //window.location.href="shoppingcart.aspx?tconid=9&bconid=12";
    var t=setTimeout("window.location.href='shoppingcart.aspx?tconid=9&bconid=12'",1000);
}

function fillUsageTypes(ctrl,id)
{           
     Anthem_InvokeControlMethod(ctrl,'FillTypeOfUseDropDownList',[id],null);    
}
    
function fillAttributeValues(ctrl,id)
{      
    //alert(id);
    Anthem_InvokeControlMethod(ctrl,'FillAttibuteTypesDropDownLists',[id], null);    
}

function fillCountry(ctrl,id)
{
    Anthem_InvokeControlMethod(ctrl,'FillCountryDropDownList',[id], null);    
}

function fillCountry2(ctrl,id)
{
    Anthem_InvokeControlMethod(ctrl,'FillCountryDropDownList',[id], function(){Anthem_PostCallBack();}  );    
}


// --------------------------------------------------------------------------------

function download_comp_click(image_id)
{
    //alert(image_id);
    parent.frames["downloadFrame"].location.href="compdownloader.aspx?cid=" + image_id;
}

function login_for_comp()
{
    alert('Please login / register to download comps, use our lightbox functions, order images or purchase rights online.If you have not already registered with Natural Visions, you may register now to gain instant access to all the features on our site.');
    
}

function comp_not_found()
{
    alert('Comp not available for this image.');
    
}

function comp_count_exceed()
{
    alert('You have exceeded maximum comp downloads allowed per day.');
    
}

// --------------------------------------------------------------------------------

function proceedPayment_click()
{ 
    //Anthem_InvokeControlMethod(ctrl,'ProceedPayment',[], null);    
    Anthem_InvokeControlMethod('ctl00_BottomResults_NV2ShoppingCart1','ProceedPayment',[], null);    
}

function homeimage_click(ctrl)
{
    AddBackEntry('nv_HomeImage', ctrl + '!nv_HomeImage');
    Anthem_InvokeControlMethod(ctrl,'ShowHomeImages',[], 
        function(result)
        {
            Anthem_PostCallBack();
        }
    );  
}


// --------------------------------------------------------------------------------
function my_serarch_go_click(drpId,ctrl)
{
    var drpObj  = document.getElementById(drpId);
    AddBackEntry('nv_Mysearch', ctrl + '!nv_Mysearch!'+ drpObj.value);
    Anthem_InvokeControlMethod(ctrl,'BtnGo_Click',[drpObj.value], function(){Anthem_PostCallBack();});  
}

function my_serarch_delete_click(drpId,ctrl)
{
    var drpObj  = document.getElementById(drpId);    
    Anthem_InvokeControlMethod(ctrl,'BtnDelete_Click',[drpObj.value], function(){Anthem_PostCallBack();});  
}


//----------------------------------------------------------------------------------
function go_to_keyword(keyid,keyword,ctrl)
{

    Anthem_InvokeControlMethod(ctrl,'GoToKeyword',[keyid,keyword], function(){Anthem_PostCallBack();}); 
}

//----------------------------------------------------------------------------------
// download items
function download_cart_item(item_id)
{
    //alert(item_id);
    var divObj  = document.getElementById('div_download_' + item_id);   
    //alert('div_download_' + item_id);
    //alert(divObj); 
    divObj.innerHTML = '<img src="images/btn/download1.gif" width="66" height="17">';
    
    parent.frames["downloadFrame"].location.href="hiresdownloader.aspx?iid=" + item_id;
}

function download_cart_item_prev(item_id)
{
    
    var divObj  = document.getElementById('div_download_' + item_id);       
    divObj.innerHTML = '<img src="images/btn/download1.gif" width="66" height="17">';
    
    parent.frames["downloadFrame"].location.href="hiresdownloader.aspx?pid=" + item_id;
}

function PrevComboChanged(imid,ctrl)
{
    var divObj  = document.getElementById('drp_SelectGroup_' + imid);   
    //alert(divObj.value);
    Anthem_InvokeControlMethod(ctrl,'drpItemChanged',[imid,divObj.value], function(){Anthem_PostCallBack();}); 
}

function ArchivedListBox_Delete(lbID, ctl)
{
    
    if ( confirm('Are you sure that you want to delete this Lightbox?') ) {
        Anthem_InvokeControlMethod(ctl,'ArchivedListbox_Delete',[lbID], function(){Anthem_PostCallBack();});
    }
}

function ArchivedListBoxDisplay(lbID, ctl,newloc,hisloc,guid)
{

    AddBackEntry(newloc, hisloc);        
    Anthem_InvokeControlMethod(ctl,'DisplayArchivedLightBox',[lbID,guid], function(){Anthem_PostCallBack();});
    //Anthem_InvokeControlMethod(ctl,'DisplayArchivedLightBox',[lbID], function(){Anthem_PostCallBack();});
    
}

function ArchivedListbox_Unarchive(lbID, ctl)
{
    Anthem_InvokeControlMethod(ctl,'ArchivedListbox_Unarchive',[lbID], function(){Anthem_PostCallBack();});
}

function ArchivedListbox_Send(lbID, ctl)
{
    Anthem_InvokeControlMethod(ctl,'ArchivedListbox_Send',[lbID], function(){Anthem_PostCallBack();});
}

function lnk_email_click(ctl)
{    
    Anthem_InvokeControlMethod(ctl,'lnkEmailLightBox_Click',[], function(){Anthem_PostCallBack();});
}