google.load("search","1");var searchArr=[];var resultArr=[];var imgContainer=document.createElement('div');var clowd1_1,clowd2_1,clowdsmall,ladeDiv_1,searchForm_div,alertmessage,about_1,aboutText_1;var call=0;var mousePos;var offsetOben=window.pageYOffset;var linkArr=[];for(var l=0;l<8;l++){linkArr[l]=[];}function getWindowWidth(win){if(win===undefined){win=window;}if(win.innerWidth){return win.innerWidth;}else{if(win.document.documentElement&&win.document.documentElement.clientWidth){return win.document.documentElement.clientWidth;}return win.document.body.offsetWidth;}}function getWindowHeight(win){if(win===undefined){win=window;}if(win.innerHeight){return win.innerHeight;}else{if(win.document.documentElement&&win.document.documentElement.clientHeight){return win.document.documentElement.clientHeight;}return win.document.body.offsetHeight;}}var width=Math.min(1600,Math.max(700,getWindowWidth()));var height=Math.min(1200,Math.max(500,getWindowHeight()));var yr,d,r;var xc=width/2+width/10;var yc=height*2/3+50;var r=Math.max(400,Math.min(width/3,height*2/3));var lwidth=r/10;function getIndex(obj){for(var i=0;i<searchArr.length;i++){if(searchArr[i]===obj){return i;}}return-1;}function emptyScreen(){for(var i=0;i<8;i++){resultArr[i]=[];}while(imgContainer.childNodes[0]){imgContainer.removeChild(imgContainer.childNodes[0]);}}function CaptureForm(){if(SearchForm.input.value.length>0){emptyScreen();window.scrollTo(0,0);call=0;ladeDiv_1=document.getElementById('ladeDiv');ladeDiv_1.style.marginTop=height/2-150+'px';ladeDiv_1.style.visibility='visible';for(var i=0;i<8;i++){searchArr[i].execute(SearchForm.input.value);}}}function positionClowds(){searchForm_div=document.getElementById('searchFormDiv');about_1=document.getElementById('about');aboutText_1=document.getElementById('aboutText');alertmessage=document.getElementById('alertmsg');haroonbaig_1=document.getElementById('haroonbaig');alertmessage.style.top=height-4*lwidth+'px';alertmessage.style.left=xc-lwidth+'px';searchForm_div.style.top=height-4*lwidth+22+'px';searchForm_div.style.left=xc-lwidth+'px';searchForm_div.style.visibility='visible';about_1.style.top=aboutText_1.style.top=height-4*lwidth+51+'px';about_1.style.left=xc-lwidth+10+'px';about_1.style.visibility='visible';aboutText_1.style.left=xc-lwidth+'px';clowd1_1=document.getElementById('clowd1');clowd1_1_front=document.getElementById('clowd1_front');clowd1_1_back=document.getElementById('clowd1_back');clowd2_1=document.getElementById('clowd2');clowd2_1_front=document.getElementById('clowd2_front');clowd2_1_back=document.getElementById('clowd2_back');clowdsmall=document.getElementById('clowd_small');clowd1_1.style.top=height-6.5*lwidth+'px';clowd1_1.style.left=xc-r-7*lwidth+'px';clowd2_1.style.top=height-8*lwidth+'px';clowd2_1.style.left=xc+r-5.8*lwidth+'px';clowd1_1_front.style.width=clowd1_1_back.style.width=11.5*lwidth+'px';clowd2_1_front.style.width=clowd2_1_back.style.width=7*lwidth+'px';clowd1_1.style.visibility=clowd2_1.style.visibility='visible';clowdsmall.style.top=yc-2.5*lwidth+'px';clowdsmall.style.left=xc-6*lwidth+'px';clowdsmall.style.visibility='visible';about_1.onmouseover=function(evt){aboutText_1.style.visibility='visible';};haroonbaig_1.onmouseover=function(evt){aboutText_1.style.visibility='visible';};aboutText_1.onmouseout=function(evt){if((evt.target||evt.srcElement).id!='haroonbaig'){aboutText_1.style.visibility='hidden';}};}function setBckgr(){var Bckgr_1=document.getElementById('bckgr');Bckgr_1.style.height='2000px';}function arrange(results,no){call=call+1;var weiss_1=document.getElementById('weiss');weiss_1.style.height=height+'px';weiss_1.style.top=height-3*lwidth+'px';var ContentDiv=document.getElementById('Content');ContentDiv.innerHTML='';var color=['#cc0000','#ff9000','#ffff00','#00cc00','#33c0c6','#0000ff','#762ca7','#ff98bf'];var d=1000;var startAngle=0;var angle;var circleAngle=360/results.length;yr=-28;for(var i=0;i<results.length;i++){var myAngle=i*circleAngle+startAngle;angle=myAngle*Math.PI/180;var result=results[i];var link=document.createElement('a');linkArr[no][i]=link;link.href=result.url;link.target='_blank';var x=(r-no*lwidth/2)*Math.cos(angle)*1.25;var y=(r-no*lwidth/2)*Math.sin(angle);var b=yr*Math.PI/180;var x2=x*Math.cos(b);var y2=y;var z2=-x*Math.sin(b);var x3=x2*d/(d+z2);var y3=-y2*d/(d+z2);link.style.left=xc+x3+'px';link.style.top=yc+y3+'px';link.style.position='absolute';link.style.zIndex=(no+1)*100-i;link.style.height=link.style.width=(4*r-x)/50+9-no+'px';link.style.overflow='hidden';link.style.border='2px solid '+color[no];var origWidth=result.tbWidth;var origHeight=result.tbHeight;var newWidth,zInd,origLeft,origTop;var newImg=document.createElement('img');newImg.src=result.tbUrl;newImg.style.position='relative';newImg.style.border="none";newImg.style.marginLeft=-(origWidth-lwidth)/2+'px';newImg.style.marginTop=-(origHeight-lwidth)/2+'px';newImg.onmouseover=function(evt){newWidth=this.width;zInd=this.parentNode.style.zIndex;origLeft=this.parentNode.offsetLeft;origTop=this.parentNode.offsetTop;this.width=origWidth;this.parentNode.style.zIndex=2000;this.parentNode.style.left=origLeft+'px';this.parentNode.style.top=origTop+'px';this.parentNode.style.overflow='visible';};newImg.onmouseout=function(evt){this.width=newWidth;this.parentNode.style.overflow='hidden';this.parentNode.style.zIndex=zInd;this.parentNode.style.left=origLeft+'px';this.parentNode.style.top=origTop+'px';};link.appendChild(newImg);imgContainer.appendChild(link);ContentDiv.appendChild(imgContainer);if(call==8&&i==63){newImg.onload=function(){setBckgr();ladeDiv_1.style.visibility='hidden';ContentDiv.style.visibility='visible';};}else{ContentDiv.style.visibility='hidden';}}function reArrange(){for(var k=0;k<8;k++){for(var j=0;j<results.length;j++){var myAngle=j*circleAngle+startAngle;var a=myAngle*Math.PI/180;var x=(r-k*lwidth/2)*Math.cos(a)*1.25;var y=(r-k*lwidth/2)*Math.sin(a);var b=yr*Math.PI/180;var x2=x*Math.cos(b);var y2=y;var z2=-x*Math.sin(b);var x3=x2*d/(d+z2);var y3=-y2*d/(d+z2);linkArr[k][j].style.width=linkArr[k][j].style.height=(4*r-x)/50+9-k+'px';linkArr[k][j].style.left=xc+x3+'px';linkArr[k][j].style.top=yc+y3+'px';}}clowd1_1.style.left=xc-r-7*lwidth+mousePos+'px';clowd1_1_front.style.width=clowd1_1_back.style.width=11.5*lwidth-2*mousePos+'px';clowd2_1.style.left=xc+r-5.8*lwidth+3*mousePos+'px';clowd2_1_front.style.width=clowd2_1_back.style.width=7*lwidth+3*mousePos+'px';clowdsmall.style.left=xc-6*lwidth+7*mousePos+'px';}window.onscroll=function(){startAngle=(window.pageYOffset-offsetOben)/8;reArrange();};window.onmousemove=function(e){mousePos=(20*e.pageX/width)-10;yr=-28+mousePos;reArrange();};window.onresize=function(){width=Math.max(800,getWindowWidth());height=Math.max(600,getWindowHeight());setBckgr();};}function clearAlert(){while(document.getElementById('alertmsg').childNodes[0]){document.getElementById('alertmsg').removeChild(document.getElementById('alertmsg').childNodes[0]);}}function Complete(searcher){if(searcher.results&&searcher.results.length>0){clearAlert();var cursor=searcher.cursor;var curPage=cursor.currentPageIndex;var indx=getIndex(searcher);for(var i=0;i<searcher.results.length;i++){resultArr[indx][(curPage)*8+i]=(searcher.results[i]);}if(curPage<cursor.pages.length){searcher.gotoPage(curPage+1);}if(resultArr[indx].length==64){arrange(resultArr[indx],indx);}}else{clearAlert();var text=document.createTextNode("sorry, but there is no "+SearchForm.input.value+" rainbow - please try again.");ladeDiv_1.style.visibility='hidden';document.getElementById('alertmsg').appendChild(text);}}function OnLoad(){var browserName=navigator.appName;if(browserName=="Microsoft Internet Explorer"){alert('This page is not working with Internet Explorer. \nSorry (ó_ò)');}else{ladeDiv_1=document.getElementById('ladeDiv');positionClowds();var colorArr=[google.search.ImageSearch.COLOR_RED,google.search.ImageSearch.COLOR_ORANGE,google.search.ImageSearch.COLOR_YELLOW,google.search.ImageSearch.COLOR_GREEN,google.search.ImageSearch.COLOR_TEAL,google.search.ImageSearch.COLOR_BLUE,google.search.ImageSearch.COLOR_PURPLE,google.search.ImageSearch.COLOR_PINK];SearchForm=new google.search.SearchForm(false,document.getElementById('searchFormDiv'));SearchForm.setOnSubmitCallback(null,CaptureForm);SearchForm.input.focus();for(var i=0;i<colorArr.length;i++){var farbe=colorArr[i];resultArr[i]=[];searchArr[i]=new google.search.ImageSearch();searchArr[i].setResultSetSize(google.search.Search.LARGE_RESULTSET);searchArr[i].setRestriction(google.search.ImageSearch.RESTRICT_COLORFILTER,[farbe]);searchArr[i].setSearchCompleteCallback(this,Complete,[searchArr[i]]);}}}google.setOnLoadCallback(OnLoad);
