﻿



var ResArr = new Array();
var CommArr = new Array();
function InitGall(divid,bigpath,Arr,GroupId){
    var contcomp = document.getElementById(divid);
    if(contcomp!=null){
        var imgcomps = contcomp.getElementsByTagName("img");
        var bigroot = bigpath;
        for(el=0;el<imgcomps.length;el++){
            var currcomp = imgcomps[el];
            if(currcomp!=null){
                if(currcomp.attributes["Gallery"]!=null){
                    if(currcomp.attributes["Gallery"].value.toUpperCase()==GroupId.toUpperCase()){
                        var dirs = currcomp.src.split("/");
                        var filename = currcomp.attributes["BigPath"].value;// bigroot + dirs[dirs.length-1];
                        var name = currcomp.attributes["GalName"]?currcomp.attributes["GalName"].value:"";
                        Arr[Arr.length] = {bigpath: filename, head: name, smallpath: currcomp.src};
                        currcomp.galid = Arr.length - 1;
                        currcomp.style.cursor = "pointer";
						//currcomp.href="#";
                        currcomp.onclick = function(){
                            ShowGallery(this.galid, Arr);
							return false;
                        }
                    }
                }
            }
        }
    }
}
function ShowGallery(Id, Arr){    
    if(Id<Arr.length){
        var btnnext = document.getElementById("btngallerynext");
        var btnprev = document.getElementById("btngalleryprev");
        var imgbig = document.getElementById("imgGalleryBig");
        var header = document.getElementById("tdGalleryHeader");
        var btnrow = document.getElementById("trgalbuuttons");
        var tdgallpage = document.getElementById("tdGalleryImageCount");
        if(header!=null && imgbig!=null && btnnext!=null && btnprev!=null && btnrow!=null && tdgallpage!=null){
            imgbig.gall = Arr;
            btnnext.style.cursor = "pointer";
            btnprev.style.cursor = "pointer";
            btnprev.style.visibility = "visible";
            btnnext.style.visibility = "visible";
            var hidcnt = new Number(0);
            btnrow.style.display = "block";
            if(Id==0){
                hidcnt++;
                btnprev.style.visibility = "hidden";
            }
            if(Id==Arr.length-1){
                hidcnt++;
                btnnext.style.visibility = "hidden";
            }
            if(hidcnt==2){
                btnrow.style.display = "none";
            }
            btnprev.gall = Arr;
            btnprev.galid = Id-1;
            btnprev.onclick = function(){
                ShowGallery(this.galid,this.gall);
            }
            btnnext.gall = Arr;
            btnnext.galid = Id+1;
            btnnext.onclick = function(){
                ShowGallery(this.galid,this.gall);
            }
            tdgallpage.innerHTML = "Image " + (Id+1) + " of " + Arr.length;
            header.innerHTML = "<b>" + Arr[Id].head + "</b>";
            imgbig.header = Arr[Id].head;
            imgbig.alt = "Loading...";
            imgbig.img = new Image();
            imgbig.img.bigsrc = Arr[Id].bigpath;
            imgbig.img.par = imgbig;
            imgbig.onload = function(){
                this.onload = null;
                window.defaultStatus = "Loading " + this.img.bigsrc;
                this.img.onload = function(){
                    this.onload = null;
                    this.par.src = this.src;
                    this.par.alt = this.par.header;
                    window.defaultStatus = "Done";
                }
                this.img.src = this.img.bigsrc;                
            }			
            window.defaultStatus = "Loading " + Arr[Id].smallpath;
            imgbig.src = Arr[Id].smallpath;
            ShowGalleryWindow();
        }
    }
}


	var visibleWindow = 0
	var ua = navigator.userAgent;
	var current_event;
	var current_X,current_Y;
	var dom = (document.getElementById) ? true : false;
	var ie4 = (document.all && !dom) ? true : false;
	var ie5_5 = ((ua.indexOf("MSIE 5.5")>=0 || ua.indexOf("MSIE 6")>=0) && ua.indexOf("Opera")<0) ? true : false;
		var ns4 = (document.layers && !dom) ? true : false;
		var offsxy = 6;
		var XmlReq1;
	 function showdiv(obj)
		{
		    //document.getElementById('txttoaddr').value=document.getElementById('hdnemail').value;
		    //document.getElementById('txtsubject').value="Invoice Reports"; 
			e = current_event;
			var curleft = curtop = 0;
			if (obj.offsetParent)
			{
				curleft = obj.offsetLeft
				curtop = obj.offsetTop
				while (obj = obj.offsetParent) 
				{
					curleft += obj.offsetLeft
					curtop += obj.offsetTop
				}
				//curleft += 50;
				curtop +=22;
			}
			
			var tooltip = atooltip();
			//tooltip.innerHTML='sivarajan';
			tooltip.style.border="1px solid #a7a7a7";
			tooltip.style.backgroundColor="#f2f2f2";

			if (ns4) {
					//tooltip.document.write(displayStr);
					//tooltip.document.close();
					tooltip.left = curleft;
					tooltip.top = curtop;
				}
				else {

					//tooltip.innerHTML = displayStr;
					tooltip.style.left = curleft+"px";
					tooltip.style.top  = curtop+"px";

					if (ie5_5) {
					tooltip.style.filter = "progid:DXImageTransform.Microsoft.DropShadow(color='b0b0b0', Direction=135, OffX='0', OffY='0') progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";
					for (i = 0; i <= 1; i++)
					{ tooltip.filters[i].Apply();
					tooltip.filters[i].Play();}
					}
				}
				with(tooltip) { ns4 ? visibility="show" : style.visibility="visible" }
			}
        function atooltip(){
            return ns4 ? document.divpopup : ie4 ? document.all.divpopup : document.getElementById('divpopup')
		}
		function deletediv()
		{
			var tooltip = atooltip();
			with(tooltip) { ns4 ? visibility="hide" : style.visibility="hidden" }
		}
   

function AddToPortfolio(Category_Name,Content_Id, oscid)
{	
	//var spn_id = 'spncheck_' + id;	
	//var spncheck = document.getElementById(spn_id);
	// check_qty = spncheck.innerHTML;
	// //alert(check_qty);		
	// if(check_qty == 1)
	// {
		// alert('This product is downloadable and can be added only once.');
	// }	
	// else
	
		
		//showdiv('divrotate');
		//var divid = 'divrotate_' + Content_Id;
		//showdiv(divid);
		//showdiv('divpixel');

		// var spntotqty = document.getElementById('spntotqty');
 		// var qty = spntotqty.innerHTML;
  		// spntotqty.innerHTML = parseInt(qty) + 1;
		// var item = parseInt(qty) + 1;
		// txtitem(item);
		// var spntotamount = document.getElementById('spntotamount');
		// amount = spntotamount.innerHTML;
			
		//totamount = parseInt(amount) + (parseInt(price));	
		
		var url = '../myportfolioajax.php?act=ad&content_id=' + Content_Id + '&cname=' + Category_Name + '&' + oscid ;
		//alert(url);
		submitForm1(url,Content_Id);	
		
	}
	
	function submitForm1(url,Content_Id)
			{           
       	 			
				var xhr;
        			try
        			{
            				xhr = new ActiveXObject('Msxml2.XMLHTTP'); 
       			 	}
        			catch (e)
        			{
            				try 
            				{
               	 				xhr = new ActiveXObject('Microsoft.XMLHTTP');    
            				}
           	 			catch (e2)
            				{
                				try 
                				{  
                    					xhr = new XMLHttpRequest();     
                				}
                				catch (e3)
                				{  
                    					xhr = false;
                				}
            				}
        			}
        			xhr.onreadystatechange  = function()
        			{ 
						if(xhr.readyState  == 4)
						{
							var Obj = document.getElementById('Itemid');
							//alert(Obj);
							//alert(xhr.status);
							if(xhr.status  == 200) 
							{
							
								//alert(xhr.responseText);
								Obj.innerHTML= xhr.responseText;
						
							}
							else
							{
								//obj.innerHTML + xhr.status;
								
							}
			
					
																									
            			}
         			};
        			xhr.open('GET', url); 
        			xhr.send(null);
				
			}
