﻿// JScript File
//open a window on button click
function openPopUp(e, link, entryID, frameid, divid, URL)
{
    var divPopUp = document.getElementById(divid);
	divPopUp.style.display = 'block';
	
	var toppx = e.screenX + 100;
	var leftpx = e.screenY;
	
	//document.getElementById('divPopUp').style.left = leftpx;
	//document.getElementById('divPopUp').style.top = toppx;
	
	var ifrm = document.getElementById(frameid);
	var str;
	
	//hardcode different buttons link, so we can pass it to the iframe src
	//tag
	if (link == 1)
	{
	    str = "member/TagUpload.aspx?entryid=" + entryID + "&parentURL=" + URL;
	}
	//wishlist
	else if (link ==2)
	{
	    str = "member/WishList.aspx?entryid=" + entryID + "&parentURL=" + URL;
	}
	//picture upload
	else if (link == 3)
	{
	    str = "member/PictureUpload.aspx?entryid=" + entryID + "&parentURL=" + URL;
	}
	//comment
	else if (link == 4)
	{
	    str = "member/Comment.aspx?entryid=" + entryID + "&parentURL=" + URL;
	}
	else if (link == 5)
	{
	    str = "Contractor/addentry.aspx?entryid=" + entryID + "&parentURL=" + URL;
	}
	
	ifrm.setAttribute('src',str);
    
    //xPos = e.screenX - 300;
    //yPos = e.screenY
    //window.open('about:blank', null, 'left='+ xPos + ',top='+ yPos  + ',width=300,height=300'); 
}

function removeWindow(link, divId)
{
    window.location.href = link; 
	var divPopUp = document.getElementById(divId);
	divPopUp.style.display = 'none';
}

function expandcontent(divobj, gid)
{
    var plus = '../App_Themes/Default/Images/plus.gif';
    var minus = '../App_Themes/Default/Images/minus.gif'; 
    var display = document.getElementById(gid).style.display;
    
    document.getElementById(gid).style.display=(display == "none" || display == "")? "block" : "none";
    document.getElementById('img' + gid).src = (document.getElementById(gid).style.display == "none")? plus : minus;
    
    //alert(divobj.src)//=(document.getElementById(gid).style.display=="none")? plus : minus; 
}

function openWindow(theURL)
{
    var height = document.body.clientHeight;
    var topht = (height - 600)/2;
    var width = document.body.clientWidth;
    var leftwdt = (width - 600)/2;
    newwindow=window.open(theURL,'name','height=400,width=600,top=' + topht + ',left=' + leftwdt + ',toolbar=no,menubar=no,location=no,status=no,scrollbars=yes');
    if (window.focus) {newwindow.focus()}
}

//this has scroll bar and it is bigger
function openContractorAddItemWindow(theURL)
{
    var height = document.body.clientHeight;
    var topht = (height - 400)/2;
    var width = document.body.clientWidth;
    var leftwdt = (width - 600)/2;
    newwindow=window.open(theURL,'name','height=600,width=800,top=' + topht + ',left=' + leftwdt + ',toolbar=no,menubar=no,location=no,status=no,scrollbars=yes');
    if (window.focus) {newwindow.focus()}
}

function toggleSearch(tab, elem)
{
    var tabElem = document.getElementById(tab);
    var divElem = document.getElementById(elem);
    
    if (tab == "prodTab")
    {
        tabElem.style.backgroundColor = "#FF7E00";
        divElem.style.display = "block";
        
        document.getElementById('contTab').style.backgroundColor = "white";
        document.getElementById('divContractor').style.display = "none";
        //document.getElementById('contTab').style.backgroundImage = "App_Themes/Default/images/signupbutton.jpg";
    }
    else if (tab == "contTab")
    {
        tabElem.style.backgroundColor = "#FF7E00";
        divElem.style.display = "block";
        
        document.getElementById('prodTab').style.backgroundColor = "white";
        document.getElementById('divProduct').style.display = "none";
    }
        
}
