var load_small = "<div class='loading'><img src='images/loading.gif' /><br />Updating... please wait</div>";
var grandtotal=0;
var prevdd=0;
var NL=0;
var cost=0;
//var hirespath;
//var lowrespath;
function UpdateSubtotal(tab, price)
{
	
	for (var i = 0; i < sections.length; i++)
	{
		if (sections[i].code == tab) 
		{
			sections[i].cost = parseInt(price);
		}
	}
	$(tab + "_subtotal1").innerHTML = "<h3>Subtotal: $" + price + "</h3>";
	$(tab + "_subtotal2").innerHTML = "<h3>Subtotal: $" + price + "</h3>";
	
	UpdateGrandTotal();
}


function ClearCompany()
{
	$("min_c_freephone").value = "";
    $("min_c_fax").value = "";
	$("min_c_freefax").value = "";
	$("min_c_email").value = "";
	$("min_c_website").value = "";
	$("min_c_mobile").value = "";
	$("CompanyName").value = "";
	$("FName").value = "";
	$("SurName").value = "";
//	$("JobTitle").value = "";
	$("min_c_postal_street").value = "";
	$("min_c_postal_suburb").value = "";
	$("min_c_postal_city").value = "";
	$("min_c_postal_postcode").value = "";
	$("min_c_postal_country").value = "";
	$("min_c_postal_street").value = "";
	$("min_c_phone").value = "";
	$("min_c_physical_street").value = "";
	$("min_c_physical_suburb").value = "";
	$("min_c_physical_city").value = "";
	$("min_c_physical_state").value = "";
	$("min_c_physical_postcode").value = "";
	$("min_c_physical_country").value = "";
	$("min_c_postal_state").value = "";
	//ScrollView('SaveCompany');
	 __doPostBack('UpdatePanel7', 'comp');
}


function ClearPerson()
{
//	$("title_person").value = "";
    $("firstname_person").value = "";
	$("lastname_person").value = "";
//	$("jobtitle_person").value = "";
	$("phone_person").value = "";
	$("fax_person").value = "";
	$("mobile_person").value = "";
	$("email_person").value = "";
//	$("FPhone").value = "";
//	$("FFax").value = "";
//	$("Web").value = "";
	$("EDITID").value = "";
}

function ClearCredit()
{
	$("cr_desc").value = "";
    $("cr_year").value = "";
    $("CREDITID").value ="";
    $("Product_Ids").value;
}

function ClearAward()
{
	$("award_desc").value = "";
    $("award_year").value = "";
    $("AWARDEDITID").value = "";
}

function ClearQual()
{
	$("qual_desc").value = "";
    $("qual_year").value = "";
    $("QUALEDITID").value = "";
}

function ClearLisitings()
{
	$("colour").checked = false;
    $("logo").checked = false;
	$("reel").checked = false;
	$("chProf").checked = false;
	$("Extra").style.display = 'none';
	$("Logos").style.display = 'none';
	$("Showreels").style.display= 'none';
	$("UploadFile3").value = "";
    $("UploadFile1").value = "";
    $("UploadFile2").value = "";
    $("web_upload").value = "";
    $("print_upload").value = "";
    $("ddCategory").options.value = "-1";
    $("ddListings").options.value = "1003";
    $("LISTEDITID").value = "";
    Element.hide("DescBB");
    Element.hide("tdcolor");
    Element.hide("tdlogo");
    Element.hide("tdshowreels");
    Element.hide("tdprof");
    Element.hide("tdonly");
  //  $("subtotal").innerHTML = "<h3>SubTotal: $0</h3>";
//    Element.hide("Credit");
    Element.hide("Award");
    Element.hide("Qualifier");
    
    

}

function UpdateGrandTotal(id)
{
   
	
        if($("ddListings").options[$("ddListings").selectedIndex].value == Boxed_Id)
        {
            grandtotal =  Boxed_Cost;
            if ($("chProf").checked)
            {
                grandtotal = grandtotal + Profile_Cost;
            }
            if ($("logo").checked)
            {
                grandtotal = grandtotal + Logo_Cost;
            }
            if ($("reel").checked)
            {
                grandtotal = grandtotal + ShowReels_Cost;
            }
            if ($("colour").checked)
            {
                grandtotal = grandtotal + Colour_Cost;
            }
	        popVisibility("Award");
	        popVisibility("Qualifier");
	        Element.show("DescBB");
	        Element.show("tdlogo");
	        Element.show("tdcolor");
            Element.show("tdshowreels");
            Element.show("tdprof");
            Element.show("tdonly");
            Element.show("Credit");
            Element.show("Award");
            Element.show("Qualifier");
            $("Descr").value = "";
	       

	    }
	    if($("ddListings").options[$("ddListings").selectedIndex].value == Bold_Id)
        {
            grandtotal =  Bold_Cost;
            if ($("chProf").checked)
            {
                grandtotal = grandtotal + Profile_Cost;
            }
            if ($("logo").checked)
            {
                grandtotal = grandtotal + Logo_Cost;
            }
            if ($("reel").checked)
            {
                grandtotal = grandtotal + ShowReels_Cost;
            }
            if ($("colour").checked)
            {
                grandtotal = grandtotal + Colour_Cost;
            }
	        popVisibility("Award");
	        popVisibility("Qualifier");
	        Element.show("tdlogo");
	        Element.show("tdcolor");
            Element.show("tdshowreels");
            Element.show("tdprof");
            Element.show("tdonly");
            Element.show("Credit");
            Element.show("Award");
            Element.show("Qualifier");
            Element.hide("DescBB");


	    }
	    if($("ddListings").options[$("ddListings").selectedIndex].value == Standard_Id)
        {
            if (NL > 0)
            {
	            grandtotal = Standard_Cost;
	        }
	       Element.hide("DescBB");
            Element.hide("tdcolor");
            Element.hide("tdlogo");
            Element.hide("tdshowreels");
            Element.hide("tdprof");
            Element.hide("tdonly");

	       hideVisibility("Award");
	       hideVisibility("Qualifier");
	       Element.show("Credit");
	    }

	$("subtotal").innerHTML = "<h3>SubTotal: $" + grandtotal + "</h3>";
	$("total").value = grandtotal;
	
	
	
	
}

function SetNumberListings(nls)
{

    NL = nls;

}

function SetCostListing(costd)
{
GoTo();
    grandtotal = costd;
}
function GoTo()
{
    alert("kkk");
}

function AllLisitngs()
{
    if ($("AllCat").checked)
	    $("SelectListings").disabled="disabled";
    else
	    $("SelectListings").disabled="none";
}


function AddToListings(id, sid, cid)
{
    $(cid).checked = false;
    if ($(id).value =="All")
    {
        $("Listing_Ids").value = "";
        $(id).value = "";
    }
    $(id).value = "";
    $("Listing_Ids").value = "";
    for (var i = 0; i < $(sid).length; i++) 
    {
        if ($(sid)[i].selected) 
        {
            $(id).value = $(id).value + $(sid)[i].text  + ";";
            $("Listing_Ids").value = $("Listing_Ids").value + $(sid)[i].value + ";";
        }
    }
    
}

function AllToListings(id, sid, acc)
{
    if ($(acc).checked == true)
    {
//        $(cid).checked = true;
        $(id).value = "All";
        $("Listing_Ids").value = "";
    }
    else
    {
        $(id).value = $(sid).options[$(sid).selectedIndex].text + ";";
        $("Listing_Ids").value = $(sid).options[$(sid).selectedIndex].value + ";";
    }
}


function AddProductType(id,sid)
{
    //var len =  $(sid).length;
    $("Product_Ids").value = '';
    $(id).value = '';
    for (var i = 0; i < $(sid).length; i++) 
    {
        if ($(sid)[i].selected) 
        {
            $(id).value = $(id).value + $(sid)[i].text + ";";
            $("Product_Ids").value = $("Product_Ids").value + $(sid)[i].value + ",";        
        }
    }


//    $(id).value = $(id).value + $(sid).options[$(sid).selectedIndex].text + ";";
//    $("Product_Ids").value = $("Product_Ids").value + $(sid).options[$(sid).selectedIndex].value + ",";

}


function ValidateCat()
{
   alert( $("ddCategory").selectedIndex);
}

function SetHiResPath()
{
    $("hirespath").value = $("print_upload").value;
}

function SetLowResPath()
{
    $("lowrespath").value = $("web_upload").value;
}

function SetP1Path()
{
    $("p1path").value = $("UploadFile1").value;
}
function SetP2Path()
{
    $("p2path").value = $("UploadFile2").value;
}
function SetP3Path()
{
    $("p3path").value = $("UploadFile3").value;
}
function toggleVisibility(controlId)        
{            
    var control = document.getElementById(controlId);            
    if(control.style.visibility == "visible" || control.style.visibility == "")
        control.style.visibility = "hidden";
    else
        control.style.visibility = "visible";
}

function popVisibility(controlId)        
{            
    var control = document.getElementById(controlId);            
    if(control.style.visibility == "hidden")
        control.style.visibility = "visible";
}
function hideVisibility(controlId)        
{            
    var control = document.getElementById(controlId);            
 //   if(control.style.visibility == "visible")
        control.style.visibility = "hidden";
}

function loadingimg(controlId)
{
    var control = document.getElementById(controlId);            
        control.value = 'Uploading...';
}

      function ScrollView(controlId)

      {
         var el = document.getElementById(controlId)
         if (el != null)
         {        
            el.scrollIntoView();
            el.focus();
         }
      }
function ClearEvent()
{
	$("event_name").value = "";
    $("event_contact").value = "";
	$("contact_phone").value = "";
	$("contact_email").value = "";
	$("start_date").value = "";
	$("end_date").value = "";
	$("Web").value = "";
	$("TextAreaDesc").value = "";
	$("released").checked = false;
	$("rmdate").value = "";
	$("Clearfield").value = "1";
}

function ScrollView(ClientID)
{
         var el = document.getElementById(ClientID)
         if (el != null)
         {        
            el.scrollIntoView();
            el.focus();
         }
}

function ValidateAll(){}